@atom8n/ai-workflow-builder 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/dist/agents/responder.agent.d.ts +21 -0
  2. package/dist/agents/responder.agent.js +71 -0
  3. package/dist/agents/responder.agent.js.map +1 -0
  4. package/dist/agents/supervisor.agent.d.ts +31 -0
  5. package/dist/agents/supervisor.agent.js +68 -0
  6. package/dist/agents/supervisor.agent.js.map +1 -0
  7. package/dist/ai-workflow-builder-agent.service.d.ts +32 -0
  8. package/dist/ai-workflow-builder-agent.service.js +236 -0
  9. package/dist/ai-workflow-builder-agent.service.js.map +1 -0
  10. package/dist/build.tsbuildinfo +1 -0
  11. package/dist/chains/conversation-compact.d.ts +7 -0
  12. package/dist/chains/conversation-compact.js +56 -0
  13. package/dist/chains/conversation-compact.js.map +1 -0
  14. package/dist/chains/parameter-updater.d.ts +16 -0
  15. package/dist/chains/parameter-updater.js +112 -0
  16. package/dist/chains/parameter-updater.js.map +1 -0
  17. package/dist/chains/prompt-categorization.d.ts +3 -0
  18. package/dist/chains/prompt-categorization.js +31 -0
  19. package/dist/chains/prompt-categorization.js.map +1 -0
  20. package/dist/chains/test/integration/test-helpers.d.ts +3 -0
  21. package/dist/chains/test/integration/test-helpers.js +16 -0
  22. package/dist/chains/test/integration/test-helpers.js.map +1 -0
  23. package/dist/chains/workflow-name.d.ts +4 -0
  24. package/dist/chains/workflow-name.js +22 -0
  25. package/dist/chains/workflow-name.js.map +1 -0
  26. package/dist/constants.d.ts +14 -0
  27. package/dist/constants.js +18 -0
  28. package/dist/constants.js.map +1 -0
  29. package/dist/errors/index.d.ts +52 -0
  30. package/dist/errors/index.js +137 -0
  31. package/dist/errors/index.js.map +1 -0
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.js +22 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/llm-config.d.ts +11 -0
  36. package/dist/llm-config.js +126 -0
  37. package/dist/llm-config.js.map +1 -0
  38. package/dist/multi-agent-workflow-subgraphs.d.ts +122 -0
  39. package/dist/multi-agent-workflow-subgraphs.js +159 -0
  40. package/dist/multi-agent-workflow-subgraphs.js.map +1 -0
  41. package/dist/parent-graph-state.d.ts +27 -0
  42. package/dist/parent-graph-state.js +47 -0
  43. package/dist/parent-graph-state.js.map +1 -0
  44. package/dist/prompts/agents/builder.prompt.d.ts +1 -0
  45. package/dist/prompts/agents/builder.prompt.js +320 -0
  46. package/dist/prompts/agents/builder.prompt.js.map +1 -0
  47. package/dist/prompts/agents/configurator.prompt.d.ts +2 -0
  48. package/dist/prompts/agents/configurator.prompt.js +143 -0
  49. package/dist/prompts/agents/configurator.prompt.js.map +1 -0
  50. package/dist/prompts/agents/discovery.prompt.d.ts +11 -0
  51. package/dist/prompts/agents/discovery.prompt.js +260 -0
  52. package/dist/prompts/agents/discovery.prompt.js.map +1 -0
  53. package/dist/prompts/agents/responder.prompt.d.ts +1 -0
  54. package/dist/prompts/agents/responder.prompt.js +41 -0
  55. package/dist/prompts/agents/responder.prompt.js.map +1 -0
  56. package/dist/prompts/agents/supervisor.prompt.d.ts +1 -0
  57. package/dist/prompts/agents/supervisor.prompt.js +43 -0
  58. package/dist/prompts/agents/supervisor.prompt.js.map +1 -0
  59. package/dist/prompts/builder/index.d.ts +2 -0
  60. package/dist/prompts/builder/index.js +7 -0
  61. package/dist/prompts/builder/index.js.map +1 -0
  62. package/dist/prompts/builder/prompt-builder.d.ts +17 -0
  63. package/dist/prompts/builder/prompt-builder.js +147 -0
  64. package/dist/prompts/builder/prompt-builder.js.map +1 -0
  65. package/dist/prompts/builder/types.d.ts +22 -0
  66. package/dist/prompts/builder/types.js +3 -0
  67. package/dist/prompts/builder/types.js.map +1 -0
  68. package/dist/prompts/chains/categorization.prompt.d.ts +43 -0
  69. package/dist/prompts/chains/categorization.prompt.js +86 -0
  70. package/dist/prompts/chains/categorization.prompt.js.map +1 -0
  71. package/dist/prompts/chains/compact.prompt.d.ts +2 -0
  72. package/dist/prompts/chains/compact.prompt.js +16 -0
  73. package/dist/prompts/chains/compact.prompt.js.map +1 -0
  74. package/dist/prompts/chains/parameter-updater/examples/if-node.d.ts +2 -0
  75. package/dist/prompts/chains/parameter-updater/examples/if-node.js +141 -0
  76. package/dist/prompts/chains/parameter-updater/examples/if-node.js.map +1 -0
  77. package/dist/prompts/chains/parameter-updater/examples/index.d.ts +6 -0
  78. package/dist/prompts/chains/parameter-updater/examples/index.js +16 -0
  79. package/dist/prompts/chains/parameter-updater/examples/index.js.map +1 -0
  80. package/dist/prompts/chains/parameter-updater/examples/resource-locator.d.ts +2 -0
  81. package/dist/prompts/chains/parameter-updater/examples/resource-locator.js +83 -0
  82. package/dist/prompts/chains/parameter-updater/examples/resource-locator.js.map +1 -0
  83. package/dist/prompts/chains/parameter-updater/examples/set-node.d.ts +2 -0
  84. package/dist/prompts/chains/parameter-updater/examples/set-node.js +151 -0
  85. package/dist/prompts/chains/parameter-updater/examples/set-node.js.map +1 -0
  86. package/dist/prompts/chains/parameter-updater/examples/simple-updates.d.ts +2 -0
  87. package/dist/prompts/chains/parameter-updater/examples/simple-updates.js +54 -0
  88. package/dist/prompts/chains/parameter-updater/examples/simple-updates.js.map +1 -0
  89. package/dist/prompts/chains/parameter-updater/examples/switch-node.d.ts +2 -0
  90. package/dist/prompts/chains/parameter-updater/examples/switch-node.js +131 -0
  91. package/dist/prompts/chains/parameter-updater/examples/switch-node.js.map +1 -0
  92. package/dist/prompts/chains/parameter-updater/examples/tool-nodes.d.ts +2 -0
  93. package/dist/prompts/chains/parameter-updater/examples/tool-nodes.js +74 -0
  94. package/dist/prompts/chains/parameter-updater/examples/tool-nodes.js.map +1 -0
  95. package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.d.ts +2 -0
  96. package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.js +70 -0
  97. package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.js.map +1 -0
  98. package/dist/prompts/chains/parameter-updater/guides/gmail.d.ts +2 -0
  99. package/dist/prompts/chains/parameter-updater/guides/gmail.js +28 -0
  100. package/dist/prompts/chains/parameter-updater/guides/gmail.js.map +1 -0
  101. package/dist/prompts/chains/parameter-updater/guides/http-request.d.ts +2 -0
  102. package/dist/prompts/chains/parameter-updater/guides/http-request.js +139 -0
  103. package/dist/prompts/chains/parameter-updater/guides/http-request.js.map +1 -0
  104. package/dist/prompts/chains/parameter-updater/guides/if-node.d.ts +2 -0
  105. package/dist/prompts/chains/parameter-updater/guides/if-node.js +159 -0
  106. package/dist/prompts/chains/parameter-updater/guides/if-node.js.map +1 -0
  107. package/dist/prompts/chains/parameter-updater/guides/index.d.ts +10 -0
  108. package/dist/prompts/chains/parameter-updater/guides/index.js +24 -0
  109. package/dist/prompts/chains/parameter-updater/guides/index.js.map +1 -0
  110. package/dist/prompts/chains/parameter-updater/guides/resource-locator.d.ts +2 -0
  111. package/dist/prompts/chains/parameter-updater/guides/resource-locator.js +99 -0
  112. package/dist/prompts/chains/parameter-updater/guides/resource-locator.js.map +1 -0
  113. package/dist/prompts/chains/parameter-updater/guides/set-node.d.ts +2 -0
  114. package/dist/prompts/chains/parameter-updater/guides/set-node.js +94 -0
  115. package/dist/prompts/chains/parameter-updater/guides/set-node.js.map +1 -0
  116. package/dist/prompts/chains/parameter-updater/guides/switch-node.d.ts +2 -0
  117. package/dist/prompts/chains/parameter-updater/guides/switch-node.js +75 -0
  118. package/dist/prompts/chains/parameter-updater/guides/switch-node.js.map +1 -0
  119. package/dist/prompts/chains/parameter-updater/guides/system-message.d.ts +2 -0
  120. package/dist/prompts/chains/parameter-updater/guides/system-message.js +96 -0
  121. package/dist/prompts/chains/parameter-updater/guides/system-message.js.map +1 -0
  122. package/dist/prompts/chains/parameter-updater/guides/text-fields.d.ts +2 -0
  123. package/dist/prompts/chains/parameter-updater/guides/text-fields.js +31 -0
  124. package/dist/prompts/chains/parameter-updater/guides/text-fields.js.map +1 -0
  125. package/dist/prompts/chains/parameter-updater/guides/tool-nodes.d.ts +2 -0
  126. package/dist/prompts/chains/parameter-updater/guides/tool-nodes.js +76 -0
  127. package/dist/prompts/chains/parameter-updater/guides/tool-nodes.js.map +1 -0
  128. package/dist/prompts/chains/parameter-updater/index.d.ts +8 -0
  129. package/dist/prompts/chains/parameter-updater/index.js +35 -0
  130. package/dist/prompts/chains/parameter-updater/index.js.map +1 -0
  131. package/dist/prompts/chains/parameter-updater/instance-url.d.ts +1 -0
  132. package/dist/prompts/chains/parameter-updater/instance-url.js +15 -0
  133. package/dist/prompts/chains/parameter-updater/instance-url.js.map +1 -0
  134. package/dist/prompts/chains/parameter-updater/parameter-updater.prompt.d.ts +4 -0
  135. package/dist/prompts/chains/parameter-updater/parameter-updater.prompt.js +52 -0
  136. package/dist/prompts/chains/parameter-updater/parameter-updater.prompt.js.map +1 -0
  137. package/dist/prompts/chains/parameter-updater/registry.d.ts +4 -0
  138. package/dist/prompts/chains/parameter-updater/registry.js +66 -0
  139. package/dist/prompts/chains/parameter-updater/registry.js.map +1 -0
  140. package/dist/prompts/chains/parameter-updater/types.d.ts +18 -0
  141. package/dist/prompts/chains/parameter-updater/types.js +3 -0
  142. package/dist/prompts/chains/parameter-updater/types.js.map +1 -0
  143. package/dist/prompts/chains/parameter-updater/utils.d.ts +2 -0
  144. package/dist/prompts/chains/parameter-updater/utils.js +16 -0
  145. package/dist/prompts/chains/parameter-updater/utils.js.map +1 -0
  146. package/dist/prompts/chains/workflow-name.prompt.d.ts +2 -0
  147. package/dist/prompts/chains/workflow-name.prompt.js +11 -0
  148. package/dist/prompts/chains/workflow-name.prompt.js.map +1 -0
  149. package/dist/prompts/index.d.ts +12 -0
  150. package/dist/prompts/index.js +50 -0
  151. package/dist/prompts/index.js.map +1 -0
  152. package/dist/prompts/legacy-agent.prompt.d.ts +6 -0
  153. package/dist/prompts/legacy-agent.prompt.js +594 -0
  154. package/dist/prompts/legacy-agent.prompt.js.map +1 -0
  155. package/dist/session-manager.service.d.ts +16 -0
  156. package/dist/session-manager.service.js +125 -0
  157. package/dist/session-manager.service.js.map +1 -0
  158. package/dist/subgraphs/builder.subgraph.d.ts +132 -0
  159. package/dist/subgraphs/builder.subgraph.js +173 -0
  160. package/dist/subgraphs/builder.subgraph.js.map +1 -0
  161. package/dist/subgraphs/configurator.subgraph.d.ts +142 -0
  162. package/dist/subgraphs/configurator.subgraph.js +173 -0
  163. package/dist/subgraphs/configurator.subgraph.js.map +1 -0
  164. package/dist/subgraphs/discovery.subgraph.d.ts +158 -0
  165. package/dist/subgraphs/discovery.subgraph.js +221 -0
  166. package/dist/subgraphs/discovery.subgraph.js.map +1 -0
  167. package/dist/subgraphs/subgraph-interface.d.ts +23 -0
  168. package/dist/subgraphs/subgraph-interface.js +7 -0
  169. package/dist/subgraphs/subgraph-interface.js.map +1 -0
  170. package/dist/tools/add-node.tool.d.ts +54 -0
  171. package/dist/tools/add-node.tool.js +176 -0
  172. package/dist/tools/add-node.tool.js.map +1 -0
  173. package/dist/tools/best-practices/chatbot.d.ts +7 -0
  174. package/dist/tools/best-practices/chatbot.js +118 -0
  175. package/dist/tools/best-practices/chatbot.js.map +1 -0
  176. package/dist/tools/best-practices/content-generation.d.ts +7 -0
  177. package/dist/tools/best-practices/content-generation.js +115 -0
  178. package/dist/tools/best-practices/content-generation.js.map +1 -0
  179. package/dist/tools/best-practices/data-analysis.d.ts +7 -0
  180. package/dist/tools/best-practices/data-analysis.js +367 -0
  181. package/dist/tools/best-practices/data-analysis.js.map +1 -0
  182. package/dist/tools/best-practices/data-extraction.d.ts +7 -0
  183. package/dist/tools/best-practices/data-extraction.js +122 -0
  184. package/dist/tools/best-practices/data-extraction.js.map +1 -0
  185. package/dist/tools/best-practices/data-transformation.d.ts +7 -0
  186. package/dist/tools/best-practices/data-transformation.js +162 -0
  187. package/dist/tools/best-practices/data-transformation.js.map +1 -0
  188. package/dist/tools/best-practices/document-processing.d.ts +7 -0
  189. package/dist/tools/best-practices/document-processing.js +335 -0
  190. package/dist/tools/best-practices/document-processing.js.map +1 -0
  191. package/dist/tools/best-practices/enrichment.d.ts +7 -0
  192. package/dist/tools/best-practices/enrichment.js +271 -0
  193. package/dist/tools/best-practices/enrichment.js.map +1 -0
  194. package/dist/tools/best-practices/form-input.d.ts +7 -0
  195. package/dist/tools/best-practices/form-input.js +173 -0
  196. package/dist/tools/best-practices/form-input.js.map +1 -0
  197. package/dist/tools/best-practices/human-in-the-loop.d.ts +7 -0
  198. package/dist/tools/best-practices/human-in-the-loop.js +268 -0
  199. package/dist/tools/best-practices/human-in-the-loop.js.map +1 -0
  200. package/dist/tools/best-practices/index.d.ts +3 -0
  201. package/dist/tools/best-practices/index.js +29 -0
  202. package/dist/tools/best-practices/index.js.map +1 -0
  203. package/dist/tools/best-practices/knowledge-base.d.ts +7 -0
  204. package/dist/tools/best-practices/knowledge-base.js +268 -0
  205. package/dist/tools/best-practices/knowledge-base.js.map +1 -0
  206. package/dist/tools/best-practices/monitoring.d.ts +7 -0
  207. package/dist/tools/best-practices/monitoring.js +178 -0
  208. package/dist/tools/best-practices/monitoring.js.map +1 -0
  209. package/dist/tools/best-practices/notification.d.ts +7 -0
  210. package/dist/tools/best-practices/notification.js +229 -0
  211. package/dist/tools/best-practices/notification.js.map +1 -0
  212. package/dist/tools/best-practices/scheduling.d.ts +7 -0
  213. package/dist/tools/best-practices/scheduling.js +281 -0
  214. package/dist/tools/best-practices/scheduling.js.map +1 -0
  215. package/dist/tools/best-practices/scraping-and-research.d.ts +7 -0
  216. package/dist/tools/best-practices/scraping-and-research.js +161 -0
  217. package/dist/tools/best-practices/scraping-and-research.js.map +1 -0
  218. package/dist/tools/best-practices/triage.d.ts +7 -0
  219. package/dist/tools/best-practices/triage.js +211 -0
  220. package/dist/tools/best-practices/triage.js.map +1 -0
  221. package/dist/tools/builder-tools.d.ts +16 -0
  222. package/dist/tools/builder-tools.js +36 -0
  223. package/dist/tools/builder-tools.js.map +1 -0
  224. package/dist/tools/categorize-prompt.tool.d.ts +5 -0
  225. package/dist/tools/categorize-prompt.tool.js +85 -0
  226. package/dist/tools/categorize-prompt.tool.js.map +1 -0
  227. package/dist/tools/connect-nodes.tool.d.ts +22 -0
  228. package/dist/tools/connect-nodes.tool.js +231 -0
  229. package/dist/tools/connect-nodes.tool.js.map +1 -0
  230. package/dist/tools/engines/node-search-engine.d.ts +16 -0
  231. package/dist/tools/engines/node-search-engine.js +123 -0
  232. package/dist/tools/engines/node-search-engine.js.map +1 -0
  233. package/dist/tools/get-best-practices.tool.d.ts +33 -0
  234. package/dist/tools/get-best-practices.tool.js +94 -0
  235. package/dist/tools/get-best-practices.tool.js.map +1 -0
  236. package/dist/tools/get-node-examples.tool.d.ts +119 -0
  237. package/dist/tools/get-node-examples.tool.js +189 -0
  238. package/dist/tools/get-node-examples.tool.js.map +1 -0
  239. package/dist/tools/get-node-parameter.tool.d.ts +4 -0
  240. package/dist/tools/get-node-parameter.tool.js +114 -0
  241. package/dist/tools/get-node-parameter.tool.js.map +1 -0
  242. package/dist/tools/get-workflow-examples.tool.d.ts +34 -0
  243. package/dist/tools/get-workflow-examples.tool.js +138 -0
  244. package/dist/tools/get-workflow-examples.tool.js.map +1 -0
  245. package/dist/tools/helpers/index.d.ts +4 -0
  246. package/dist/tools/helpers/index.js +21 -0
  247. package/dist/tools/helpers/index.js.map +1 -0
  248. package/dist/tools/helpers/progress.d.ts +9 -0
  249. package/dist/tools/helpers/progress.js +126 -0
  250. package/dist/tools/helpers/progress.js.map +1 -0
  251. package/dist/tools/helpers/response.d.ts +7 -0
  252. package/dist/tools/helpers/response.js +33 -0
  253. package/dist/tools/helpers/response.js.map +1 -0
  254. package/dist/tools/helpers/state.d.ts +14 -0
  255. package/dist/tools/helpers/state.js +85 -0
  256. package/dist/tools/helpers/state.js.map +1 -0
  257. package/dist/tools/helpers/validation.d.ts +13 -0
  258. package/dist/tools/helpers/validation.js +83 -0
  259. package/dist/tools/helpers/validation.js.map +1 -0
  260. package/dist/tools/node-details.tool.d.ts +31 -0
  261. package/dist/tools/node-details.tool.js +201 -0
  262. package/dist/tools/node-details.tool.js.map +1 -0
  263. package/dist/tools/node-search.tool.d.ts +62 -0
  264. package/dist/tools/node-search.tool.js +155 -0
  265. package/dist/tools/node-search.tool.js.map +1 -0
  266. package/dist/tools/remove-connection.tool.d.ts +24 -0
  267. package/dist/tools/remove-connection.tool.js +234 -0
  268. package/dist/tools/remove-connection.tool.js.map +1 -0
  269. package/dist/tools/remove-node.tool.d.ts +4 -0
  270. package/dist/tools/remove-node.tool.js +106 -0
  271. package/dist/tools/remove-node.tool.js.map +1 -0
  272. package/dist/tools/update-node-parameters.tool.d.ts +5 -0
  273. package/dist/tools/update-node-parameters.tool.js +156 -0
  274. package/dist/tools/update-node-parameters.tool.js.map +1 -0
  275. package/dist/tools/utils/connection-parameters.utils.d.ts +8 -0
  276. package/dist/tools/utils/connection-parameters.utils.js +47 -0
  277. package/dist/tools/utils/connection-parameters.utils.js.map +1 -0
  278. package/dist/tools/utils/connection.utils.d.ts +15 -0
  279. package/dist/tools/utils/connection.utils.js +321 -0
  280. package/dist/tools/utils/connection.utils.js.map +1 -0
  281. package/dist/tools/utils/mermaid.utils.d.ts +13 -0
  282. package/dist/tools/utils/mermaid.utils.js +647 -0
  283. package/dist/tools/utils/mermaid.utils.js.map +1 -0
  284. package/dist/tools/utils/node-configuration.utils.d.ts +13 -0
  285. package/dist/tools/utils/node-configuration.utils.js +75 -0
  286. package/dist/tools/utils/node-configuration.utils.js.map +1 -0
  287. package/dist/tools/utils/node-creation.utils.d.ts +8 -0
  288. package/dist/tools/utils/node-creation.utils.js +56 -0
  289. package/dist/tools/utils/node-creation.utils.js.map +1 -0
  290. package/dist/tools/utils/node-positioning.utils.d.ts +17 -0
  291. package/dist/tools/utils/node-positioning.utils.js +87 -0
  292. package/dist/tools/utils/node-positioning.utils.js.map +1 -0
  293. package/dist/tools/utils/parameter-update.utils.d.ts +6 -0
  294. package/dist/tools/utils/parameter-update.utils.js +75 -0
  295. package/dist/tools/utils/parameter-update.utils.js.map +1 -0
  296. package/dist/tools/utils/test/workflows/ai-assistant.workflow.d.ts +2 -0
  297. package/dist/tools/utils/test/workflows/ai-assistant.workflow.js +542 -0
  298. package/dist/tools/utils/test/workflows/ai-assistant.workflow.js.map +1 -0
  299. package/dist/tools/validate-configuration.tool.d.ts +4 -0
  300. package/dist/tools/validate-configuration.tool.js +70 -0
  301. package/dist/tools/validate-configuration.tool.js.map +1 -0
  302. package/dist/tools/validate-structure.tool.d.ts +4 -0
  303. package/dist/tools/validate-structure.tool.js +66 -0
  304. package/dist/tools/validate-structure.tool.js.map +1 -0
  305. package/dist/tools/validate-workflow.tool.d.ts +5 -0
  306. package/dist/tools/validate-workflow.tool.js +73 -0
  307. package/dist/tools/validate-workflow.tool.js.map +1 -0
  308. package/dist/tools/web/templates.d.ts +23 -0
  309. package/dist/tools/web/templates.js +106 -0
  310. package/dist/tools/web/templates.js.map +1 -0
  311. package/dist/types/best-practices.d.ts +6 -0
  312. package/dist/types/best-practices.js +3 -0
  313. package/dist/types/best-practices.js.map +1 -0
  314. package/dist/types/categorization.d.ts +23 -0
  315. package/dist/types/categorization.js +38 -0
  316. package/dist/types/categorization.js.map +1 -0
  317. package/dist/types/config.d.ts +55 -0
  318. package/dist/types/config.js +3 -0
  319. package/dist/types/config.js.map +1 -0
  320. package/dist/types/connections.d.ts +30 -0
  321. package/dist/types/connections.js +3 -0
  322. package/dist/types/connections.js.map +1 -0
  323. package/dist/types/coordination.d.ts +42 -0
  324. package/dist/types/coordination.js +23 -0
  325. package/dist/types/coordination.js.map +1 -0
  326. package/dist/types/discovery-types.d.ts +12 -0
  327. package/dist/types/discovery-types.js +3 -0
  328. package/dist/types/discovery-types.js.map +1 -0
  329. package/dist/types/index.d.ts +11 -0
  330. package/dist/types/index.js +18 -0
  331. package/dist/types/index.js.map +1 -0
  332. package/dist/types/langchain.d.ts +3 -0
  333. package/dist/types/langchain.js +15 -0
  334. package/dist/types/langchain.js.map +1 -0
  335. package/dist/types/messages.d.ts +32 -0
  336. package/dist/types/messages.js +3 -0
  337. package/dist/types/messages.js.map +1 -0
  338. package/dist/types/nodes.d.ts +27 -0
  339. package/dist/types/nodes.js +3 -0
  340. package/dist/types/nodes.js.map +1 -0
  341. package/dist/types/sessions.d.ts +8 -0
  342. package/dist/types/sessions.js +34 -0
  343. package/dist/types/sessions.js.map +1 -0
  344. package/dist/types/streaming.d.ts +33 -0
  345. package/dist/types/streaming.js +3 -0
  346. package/dist/types/streaming.js.map +1 -0
  347. package/dist/types/tools.d.ts +120 -0
  348. package/dist/types/tools.js +3 -0
  349. package/dist/types/tools.js.map +1 -0
  350. package/dist/types/utils.d.ts +2 -0
  351. package/dist/types/utils.js +3 -0
  352. package/dist/types/utils.js.map +1 -0
  353. package/dist/types/web/templates.d.ts +45 -0
  354. package/dist/types/web/templates.js +37 -0
  355. package/dist/types/web/templates.js.map +1 -0
  356. package/dist/types/workflow.d.ts +31 -0
  357. package/dist/types/workflow.js +3 -0
  358. package/dist/types/workflow.js.map +1 -0
  359. package/dist/utils/cache-control/helpers.d.ts +5 -0
  360. package/dist/utils/cache-control/helpers.js +126 -0
  361. package/dist/utils/cache-control/helpers.js.map +1 -0
  362. package/dist/utils/cache-control/index.d.ts +1 -0
  363. package/dist/utils/cache-control/index.js +9 -0
  364. package/dist/utils/cache-control/index.js.map +1 -0
  365. package/dist/utils/cleanup-dangling-tool-call-messages.d.ts +3 -0
  366. package/dist/utils/cleanup-dangling-tool-call-messages.js +10 -0
  367. package/dist/utils/cleanup-dangling-tool-call-messages.js.map +1 -0
  368. package/dist/utils/context-builders.d.ts +10 -0
  369. package/dist/utils/context-builders.js +71 -0
  370. package/dist/utils/context-builders.js.map +1 -0
  371. package/dist/utils/coordination-log.d.ts +15 -0
  372. package/dist/utils/coordination-log.js +75 -0
  373. package/dist/utils/coordination-log.js.map +1 -0
  374. package/dist/utils/http-proxy-agent.d.ts +2 -0
  375. package/dist/utils/http-proxy-agent.js +16 -0
  376. package/dist/utils/http-proxy-agent.js.map +1 -0
  377. package/dist/utils/node-helpers.d.ts +2 -0
  378. package/dist/utils/node-helpers.js +54 -0
  379. package/dist/utils/node-helpers.js.map +1 -0
  380. package/dist/utils/operations-processor.d.ts +14 -0
  381. package/dist/utils/operations-processor.js +196 -0
  382. package/dist/utils/operations-processor.js.map +1 -0
  383. package/dist/utils/state-modifier.d.ts +32 -0
  384. package/dist/utils/state-modifier.js +112 -0
  385. package/dist/utils/state-modifier.js.map +1 -0
  386. package/dist/utils/state-reducers.d.ts +3 -0
  387. package/dist/utils/state-reducers.js +20 -0
  388. package/dist/utils/state-reducers.js.map +1 -0
  389. package/dist/utils/stream-processor.d.ts +20 -0
  390. package/dist/utils/stream-processor.js +277 -0
  391. package/dist/utils/stream-processor.js.map +1 -0
  392. package/dist/utils/subgraph-helpers.d.ts +16 -0
  393. package/dist/utils/subgraph-helpers.js +117 -0
  394. package/dist/utils/subgraph-helpers.js.map +1 -0
  395. package/dist/utils/token-usage.d.ts +21 -0
  396. package/dist/utils/token-usage.js +45 -0
  397. package/dist/utils/token-usage.js.map +1 -0
  398. package/dist/utils/tool-executor.d.ts +3 -0
  399. package/dist/utils/tool-executor.js +108 -0
  400. package/dist/utils/tool-executor.js.map +1 -0
  401. package/dist/utils/trim-workflow-context.d.ts +2 -0
  402. package/dist/utils/trim-workflow-context.js +53 -0
  403. package/dist/utils/trim-workflow-context.js.map +1 -0
  404. package/dist/utils/workflow-validation.d.ts +2 -0
  405. package/dist/utils/workflow-validation.js +37 -0
  406. package/dist/utils/workflow-validation.js.map +1 -0
  407. package/dist/validation/checks/agent-prompt.d.ts +3 -0
  408. package/dist/validation/checks/agent-prompt.js +47 -0
  409. package/dist/validation/checks/agent-prompt.js.map +1 -0
  410. package/dist/validation/checks/connections.d.ts +4 -0
  411. package/dist/validation/checks/connections.js +163 -0
  412. package/dist/validation/checks/connections.js.map +1 -0
  413. package/dist/validation/checks/credentials.d.ts +3 -0
  414. package/dist/validation/checks/credentials.js +125 -0
  415. package/dist/validation/checks/credentials.js.map +1 -0
  416. package/dist/validation/checks/from-ai.d.ts +4 -0
  417. package/dist/validation/checks/from-ai.js +62 -0
  418. package/dist/validation/checks/from-ai.js.map +1 -0
  419. package/dist/validation/checks/index.d.ts +7 -0
  420. package/dist/validation/checks/index.js +18 -0
  421. package/dist/validation/checks/index.js.map +1 -0
  422. package/dist/validation/checks/nodes.d.ts +4 -0
  423. package/dist/validation/checks/nodes.js +44 -0
  424. package/dist/validation/checks/nodes.js.map +1 -0
  425. package/dist/validation/checks/tools.d.ts +4 -0
  426. package/dist/validation/checks/tools.js +38 -0
  427. package/dist/validation/checks/tools.js.map +1 -0
  428. package/dist/validation/checks/trigger.d.ts +8 -0
  429. package/dist/validation/checks/trigger.js +33 -0
  430. package/dist/validation/checks/trigger.js.map +1 -0
  431. package/dist/validation/programmatic.d.ts +3 -0
  432. package/dist/validation/programmatic.js +24 -0
  433. package/dist/validation/programmatic.js.map +1 -0
  434. package/dist/validation/types.d.ts +52 -0
  435. package/dist/validation/types.js +31 -0
  436. package/dist/validation/types.js.map +1 -0
  437. package/dist/validation/utils/expressions.d.ts +3 -0
  438. package/dist/validation/utils/expressions.js +37 -0
  439. package/dist/validation/utils/expressions.js.map +1 -0
  440. package/dist/validation/utils/is-tool.d.ts +2 -0
  441. package/dist/validation/utils/is-tool.js +7 -0
  442. package/dist/validation/utils/is-tool.js.map +1 -0
  443. package/dist/validation/utils/node-type-map.d.ts +8 -0
  444. package/dist/validation/utils/node-type-map.js +50 -0
  445. package/dist/validation/utils/node-type-map.js.map +1 -0
  446. package/dist/validation/utils/resolve-connections.d.ts +8 -0
  447. package/dist/validation/utils/resolve-connections.js +64 -0
  448. package/dist/validation/utils/resolve-connections.js.map +1 -0
  449. package/dist/workflow-builder-agent.d.ts +72 -0
  450. package/dist/workflow-builder-agent.js +401 -0
  451. package/dist/workflow-builder-agent.js.map +1 -0
  452. package/dist/workflow-state.d.ts +26 -0
  453. package/dist/workflow-state.js +79 -0
  454. package/dist/workflow-state.js.map +1 -0
  455. package/package.json +77 -0
@@ -0,0 +1,594 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mainAgentPrompt = void 0;
4
+ exports.createMainAgentPrompt = createMainAgentPrompt;
5
+ const prompts_1 = require("@langchain/core/prompts");
6
+ const instance_url_1 = require("./chains/parameter-updater/instance-url");
7
+ function generateWorkflowCreationPhases(options = {}) {
8
+ const { includeExamplesPhase = false } = options;
9
+ const phases = [
10
+ {
11
+ name: 'Categorization Phase',
12
+ metadata: '- MANDATORY',
13
+ content: [
14
+ 'Categorize the prompt and search for best practices documentation based on the techniques found',
15
+ 'Why: Best practices help to inform which nodes to search for and use to build the workflow plus mistakes to avoid',
16
+ ],
17
+ },
18
+ ];
19
+ if (includeExamplesPhase) {
20
+ phases.push({
21
+ name: 'Examples Phase',
22
+ metadata: '(parallel execution)',
23
+ content: [
24
+ 'Search for workflow examples using simple, relevant search terms',
25
+ 'Why: Examples provide complete, working implementations showing nodes, connections and parameter configurations',
26
+ ],
27
+ });
28
+ }
29
+ phases.push({
30
+ name: 'Discovery Phase',
31
+ metadata: '(parallel execution)',
32
+ content: [
33
+ 'Search for all required node types simultaneously, review the <node_selection> section for tips and best practices',
34
+ 'Why: Ensures you work with actual available nodes, not assumptions',
35
+ ],
36
+ }, {
37
+ name: 'Analysis Phase',
38
+ metadata: '(parallel execution)',
39
+ content: [
40
+ 'Get details for ALL nodes before proceeding',
41
+ 'Why: Understanding inputs/outputs prevents connection errors and ensures proper parameter configuration',
42
+ ],
43
+ }, {
44
+ name: 'Creation Phase',
45
+ metadata: '(parallel execution)',
46
+ content: [
47
+ 'Add nodes individually by calling add_nodes for each node',
48
+ 'Execute multiple add_nodes calls in parallel for efficiency',
49
+ 'Why: Each node addition is independent, parallel execution is faster, and the operations processor ensures consistency',
50
+ ],
51
+ }, {
52
+ name: 'Connection Phase',
53
+ metadata: '(parallel execution)',
54
+ content: [
55
+ 'Connect all nodes based on discovered input/output structure',
56
+ 'Why: Parallel connections are safe and faster',
57
+ ],
58
+ }, {
59
+ name: 'Configuration Phase',
60
+ metadata: '(parallel execution) - MANDATORY',
61
+ content: [
62
+ 'ALWAYS configure nodes using update_node_parameters',
63
+ 'Even for "simple" nodes like HTTP Request, Set, etc.',
64
+ 'Configure all nodes in parallel for efficiency',
65
+ 'Why: Unconfigured nodes will fail at runtime',
66
+ 'Pay special attention to parameters that control node behavior (dataType, mode, operation)',
67
+ 'Why: Unconfigured nodes will fail at runtime, defaults are unreliable',
68
+ ],
69
+ }, {
70
+ name: 'Validation Phase',
71
+ metadata: '(tool call) - MANDATORY',
72
+ content: [
73
+ 'Run validate_workflow after applying changes to refresh the workflow validation report',
74
+ 'Review <workflow_validation_report> and resolve any violations before finalizing',
75
+ 'Why: Ensures structural issues are surfaced early; rerun validation after major updates',
76
+ ],
77
+ });
78
+ return phases
79
+ .map((phase, index) => {
80
+ const phaseNumber = index + 1;
81
+ const metadataStr = phase.metadata ? ` ${phase.metadata}` : '';
82
+ const contentStr = phase.content.map((line) => ` - ${line}`).join('\n');
83
+ return `${phaseNumber}. **${phase.name}**${metadataStr}\n${contentStr}`;
84
+ })
85
+ .join('\n\n');
86
+ }
87
+ function generateSystemPrompt(options = {}) {
88
+ const workflowPhases = generateWorkflowCreationPhases(options);
89
+ return `You are an AI assistant specialized in creating and editing n8n workflows. Your goal is to help users build efficient, well-connected workflows by intelligently using the available tools.
90
+ <core_principle>
91
+ After receiving tool results, reflect on their quality and determine optimal next steps. Use this reflection to plan your approach and ensure all nodes are properly configured and connected.
92
+ </core_principle>
93
+
94
+ <communication_style>
95
+ CRITICAL: Do NOT provide commentary between tool calls. Execute tools silently.
96
+ - NO emojis under any circumstances
97
+ - NO progress messages like "Perfect!", "Now let me...", "Excellent!"
98
+ - NO descriptions of what was built or how it works
99
+ - NO workflow features or capabilities explanations
100
+ - Only respond AFTER all tools are complete
101
+ - Response should only contain setup/usage information
102
+ </communication_style>
103
+
104
+
105
+ Parallel execution guidelines:
106
+ - ALL tools support parallel execution, including add_nodes
107
+ - Information gathering: Call search_nodes and get_node_details in parallel for multiple node types
108
+ - Node creation: Add multiple nodes by calling add_nodes multiple times in parallel
109
+ - Parameter updates: Update different nodes' parameters simultaneously
110
+ - Connection creation: Connect multiple node pairs simultaneously
111
+
112
+ The system's operations processor ensures state consistency across all parallel operations.
113
+ </tool_execution_strategy>
114
+
115
+ <workflow_creation_sequence>
116
+ Follow this proven sequence for creating robust workflows:
117
+
118
+ ${workflowPhases}
119
+
120
+ <node_selection>
121
+ When building AI workflows prefer the AI agent node to other text LLM nodes, unless the user specifies them by name. Summarization, analysis, information
122
+ extraction and classification can all be carried out by an AI agent node, correct system prompt, and structured output parser.
123
+ For the purposes of this section provider specific nodes can be described as nodes like @n8n/n8n-nodes-langchain.openAi.
124
+ Do not use provider specific nodes for text operations - instead use an AI agent node.
125
+ For generation/analysis of content other than text (images, video, audio) provider specific nodes should be used.
126
+ </node_selection>
127
+
128
+ <best_practices_compliance>
129
+ Enforcing best practice compliance is MANDATORY
130
+
131
+ You MUST enforce best practices even when the user doesn't explicitly request them. Best practices document CRITICAL requirements that prevent production failures.
132
+
133
+ When you retrieve best practices and see CRITICAL requirements:
134
+ 1. Identify all MUST-HAVE nodes and configurations
135
+ 2. Add them to your workflow plan
136
+ 3. Include them in the workflow even if user didn't explicitly ask
137
+ 4. Mention them in your setup response so user understands why they're there
138
+ </best_practices_compliance>
139
+
140
+ <parallel_node_creation_example>
141
+ Example: Creating and configuring a workflow (complete process):
142
+
143
+ Step 1 - Add nodes in parallel:
144
+ - add_nodes({{ nodeType: "n8n-nodes-base.httpRequest", name: "Fetch Data", ... }})
145
+ - add_nodes({{ nodeType: "n8n-nodes-base.set", name: "Transform Data", ... }})
146
+
147
+ Step 2 - Connect nodes:
148
+ - connect_nodes({{ sourceNodeId: "Fetch Data", targetNodeId: "Transform Data" }})
149
+
150
+ Step 3 - Configure ALL nodes in parallel (MANDATORY):
151
+ - update_node_parameters({{ nodeId: "Fetch Data", instructions: ["Set URL to https://api.example.com/users", "Set method to GET"] }})
152
+ - update_node_parameters({{ nodeId: "Transform Data", instructions: ["Add field status with value 'processed'", "Add field timestamp with current date"] }})
153
+
154
+ Step 4 - Validate workflow:
155
+ - validate_workflow()
156
+ - If there are validation errors or warnings, address them by returning to the appropriate phase.
157
+ </parallel_node_creation_example>
158
+ </workflow_creation_sequence>
159
+
160
+ <connection_parameters_rules>
161
+ Every node addition requires both reasoning and parameters. Each add_nodes call adds a single node.
162
+ This two-step process ensures proper connections:
163
+
164
+ <reasoning_first>
165
+ Always determine connectionParametersReasoning before setting connectionParameters. Ask yourself:
166
+ - Does this node have dynamic inputs/outputs?
167
+ - Which parameters affect the connection structure?
168
+ - What mode or operation changes the available connections?
169
+ - Are there best practices which provide recommendations for connections?
170
+ </reasoning_first>
171
+
172
+ <parameter_examples>
173
+ Static nodes (standard inputs/outputs):
174
+ - HTTP Request, Set, Code: reasoning="Static inputs/outputs", parameters={{}}
175
+
176
+ Dynamic nodes (parameter-dependent connections):
177
+ - AI Agent with parser: reasoning="hasOutputParser creates additional input for schema", parameters={{ hasOutputParser: true }}
178
+ - Vector Store insert: reasoning="Insert mode requires document input", parameters={{ mode: "insert" }}
179
+ - Vector Store as tool: reasoning="Tool mode provides AI connection output", parameters={{ mode: "retrieve-as-tool" }}
180
+ - Document Loader custom: reasoning="Custom mode enables text splitter input", parameters={{ textSplittingMode: "custom" }}
181
+ - Document Loader binary: reasoning="Binary mode for processing files instead of JSON", parameters={{ dataType: "binary" }}
182
+ </parameter_examples>
183
+ </connection_parameters_rules>
184
+
185
+ <node_connections_understanding>
186
+ n8n connections flow from SOURCE (output) to TARGET (input).
187
+
188
+ <main_connections>
189
+ Regular data flow: Source node output → Target node input
190
+ Example: HTTP Request → Set (HTTP Request is source, Set is target)
191
+ </main_connections>
192
+
193
+ <ai_connections>
194
+ AI sub-nodes PROVIDE capabilities, making them the SOURCE:
195
+ - OpenAI Chat Model → AI Agent [ai_languageModel]
196
+ - Calculator Tool → AI Agent [ai_tool]
197
+ - Window Buffer Memory → AI Agent [ai_memory]
198
+ - Token Splitter → Default Data Loader [ai_textSplitter]
199
+ - Default Data Loader → Vector Store [ai_document]
200
+ - Embeddings OpenAI → Vector Store [ai_embedding]
201
+ Why: Sub-nodes enhance main nodes with their capabilities
202
+ </ai_connections>
203
+
204
+ <rag_workflow_pattern>
205
+ CRITICAL: For RAG (Retrieval-Augmented Generation) workflows, follow this specific pattern:
206
+
207
+ Main data flow:
208
+ - Data source (e.g., HTTP Request) → Vector Store [main connection]
209
+ - The Vector Store receives the actual data through its main input
210
+
211
+ AI capability connections:
212
+ - Document Loader → Vector Store [ai_document] - provides document processing
213
+ - Embeddings → Vector Store [ai_embedding] - provides embedding generation
214
+ - Text Splitter → Document Loader [ai_textSplitter] - provides text chunking
215
+
216
+ Common mistake to avoid:
217
+ - NEVER connect Document Loader to main data outputs
218
+ - Document Loader is NOT a data processor in the main flow
219
+ - Document Loader is an AI sub-node that gives Vector Store or Summarization Chain the ability to process documents
220
+
221
+ Example RAG workflow:
222
+ 1. Schedule Trigger → HTTP Request (download PDF)
223
+ 2. HTTP Request → Vector Store (main data flow)
224
+ 3. Token Splitter → Document Loader [ai_textSplitter]
225
+ 4. Document Loader → Vector Store [ai_document]
226
+ 5. OpenAI Embeddings → Vector Store [ai_embedding]
227
+
228
+ Why: Vector Store needs three things: data (main input), document processing capability (Document Loader), and embedding capability (Embeddings)
229
+ </rag_workflow_pattern>
230
+ </node_connections_understanding>
231
+
232
+ <agent_node_distinction>
233
+ CRITICAL: Distinguish between two different agent node types:
234
+
235
+ 1. **AI Agent** (n8n-nodes-langchain.agent)
236
+ - Main workflow node that orchestrates AI tasks
237
+ - Accepts inputs: trigger data, memory, tools, language models
238
+ - Use for: Primary AI logic, chatbots, autonomous workflows
239
+ - Example: "Add an AI agent to analyze customer emails"
240
+
241
+ 2. **AI Agent Tool** (n8n-nodes-langchain.agentTool)
242
+ - Sub-node that acts as a tool for another AI Agent
243
+ - Provides agent-as-a-tool capability to parent agents
244
+ - Use for: Multi-agent systems where one agent calls another
245
+ - Example: "Add a research agent tool for the main agent to use"
246
+
247
+ Default assumption: When users ask for "an agent" or "AI agent", they mean the main AI Agent node unless they explicitly mention "tool", "sub-agent", or "agent for another agent".
248
+ </agent_node_distinction>
249
+
250
+ <node_defaults_warning>
251
+ ⚠️ CRITICAL: NEVER RELY ON DEFAULT PARAMETER VALUES ⚠️
252
+
253
+ Default values are a common source of runtime failures. You MUST explicitly configure ALL parameters that control node behavior, even if they have defaults.
254
+
255
+ Common failures from relying on defaults:
256
+ - Document Loader: Defaults to dataType='json' but MUST be set to 'binary' when processing files (PDFs, DOCX, etc.)
257
+ - Vector Store: Mode parameter affects available connections - always set explicitly
258
+ - AI Agent: hasOutputParser default may not match your workflow needs
259
+ - HTTP Request: Default method is GET but many APIs require POST
260
+ - Database nodes: Default operations may not match intended behavior
261
+
262
+ ALWAYS check node details obtained in Analysis Phase and configure accordingly. Defaults are NOT your friend - they are traps that cause workflows to fail at runtime.
263
+ </node_defaults_warning>
264
+
265
+ <workflow_configuration_node>
266
+ CRITICAL: Always include a Workflow Configuration node at the start of every workflow.
267
+
268
+ The Workflow Configuration node (n8n-nodes-base.set) is a mandatory node that should be placed immediately after the trigger node and before all other processing nodes.
269
+ This node centralizes workflow-wide settings and parameters that other nodes can reference throughout the execution with expressions.
270
+
271
+ Placement rules:
272
+ - ALWAYS add between trigger and first processing node
273
+ - Connect: Trigger → Workflow Configuration → First processing node
274
+ - This creates a single source of truth for workflow parameters
275
+
276
+ Configuration approach:
277
+ - Include URLs, thresholds, string constants and any reusable values
278
+ - Other nodes reference these via expressions: {{ $('Workflow Configuration').first().json.variableName }}
279
+ - Add only parameters that are used by other nodes, DO NOT add unnecessary fields
280
+
281
+ Workflow configuration node usage example:
282
+ 1. Schedule Trigger → Workflow Configuration → HTTP Request → Process Data
283
+ 2. Add field apiUrl to the Workflow Configuration node with value "https://api.example.com/data"
284
+ 3. Reference in HTTP Request node: "{{ $('Workflow Configuration').first().json.apiUrl }}" instead of directly setting the URL
285
+
286
+ IMPORTANT:
287
+ - Workflow Configuration node is not meant for credentials or sensitive data.
288
+ - Always enable "includeOtherFields" setting of the Workflow Configuration node, to pass to the output all the input fields (this is a top level parameter, do not add it to the fields in 'Fields to Set' parameter).
289
+ - Do not reference the variables from the Workflow Configuration node in Trigger nodes (as they run before it).
290
+
291
+ Why: Centralizes configuration, makes workflows maintainable, enables easy environment switching, and provides clear parameter visibility.
292
+ </workflow_configuration_node>
293
+
294
+ <configuration_requirements>
295
+ ALWAYS configure nodes after adding and connecting them. This is NOT optional.
296
+
297
+ Use update_node_parameters for EVERY node that processes data:
298
+ - HTTP Request: MUST set URL, method, headers
299
+ - Set: MUST define fields to set
300
+ - Code: MUST provide the code to execute
301
+ - AI nodes: MUST configure prompts and models
302
+ - Database nodes: MUST set queries
303
+ - Trigger nodes: MUST define schedules/conditions
304
+ - Tool nodes: Use $fromAI expressions for dynamic values based on context (recipients, subjects, messages, dates)
305
+ - Document Loader: MUST set dataType parameter - 'json' for JSON data, 'binary' for files (PDF, DOCX, etc.)
306
+ - When processing files, ALWAYS set dataType to 'binary' - the default 'json' will cause failures
307
+ - Also configure loader type, text splitting mode, and other parameters based on use case
308
+
309
+ Only skip configuration for pure routing nodes (like Switch) that work with defaults.
310
+
311
+ Configure multiple nodes in parallel:
312
+ - update_node_parameters({{ nodeId: "httpRequest1", instructions: ["Set URL to https://api.example.com/data", "Add header Authorization: Bearer token"] }})
313
+ - update_node_parameters({{ nodeId: "set1", instructions: ["Add field 'processed' with value true", "Add field 'timestamp' with current date"] }})
314
+ - update_node_parameters({{ nodeId: "code1", instructions: ["Parse JSON input", "Extract and return user emails array"] }})
315
+ - update_node_parameters({{ nodeId: "gmailTool1", instructions: ["Set sendTo to ={{ $fromAI('to') }}", "Set subject to \${{ $fromAI('subject') }}", "Set message to =\${{ $fromAI('message_html') }}"] }})
316
+ - update_node_parameters({{ nodeId: "documentLoader1", instructions: ["Set dataType to 'binary' for processing PDF files", "Set loader to 'pdfLoader'", "Enable splitPages option"] }})
317
+
318
+ Why: Unconfigured nodes WILL fail at runtime
319
+
320
+ <system_message_configuration>
321
+ CRITICAL: For AI nodes (AI Agent, LLM Chain, Anthropic, OpenAI, etc.), you MUST separate system-level instructions from user context.
322
+
323
+ **System Message vs User Prompt:**
324
+ - **System Message** = AI's ROLE, CAPABILITIES, TASK DESCRIPTION, and BEHAVIORAL INSTRUCTIONS
325
+ - **User Message/Text** = DYNAMIC USER INPUT, CONTEXT VARIABLES, and DATA REFERENCES
326
+
327
+ **Node-specific field names:**
328
+ - AI Agent: system message goes in options.systemMessage, user context in text
329
+ - LLM Chain: system message in messages.messageValues[] with system role, user context in text
330
+ - Anthropic: system message in options.system, user context in messages.values[]
331
+ - OpenAI: system message in messages.values[] with role "system", user in messages.values[] with role "user"
332
+
333
+ **System Message** should contain:
334
+ - AI identity and role ("You are a...")
335
+ - Task description ("Your task is to...")
336
+ - Step-by-step instructions
337
+ - Behavioral guidelines
338
+ - Expected output format
339
+ - Coordination instructions
340
+
341
+ **User Message/Text** should contain:
342
+ - Dynamic data from workflow (expressions like {{ $json.field }})
343
+ - User input references ({{ $json.chatInput }})
344
+ - Context variables from previous nodes
345
+ - Minimal instruction (just what varies per execution)
346
+
347
+ **WRONG - Everything in text/user message field:**
348
+ ❌ text: "=You are an orchestrator that coordinates specialized AI tasks. Your task is to: 1) Call Research Tool 2) Call Fact-Check Tool 3) Return HTML. The research topic is: {{ $json.researchTopic }}"
349
+
350
+ **RIGHT - Properly separated:**
351
+ ✅ text: "=The research topic is: {{ $json.researchTopic }}"
352
+ ✅ System message: "You are an orchestrator that coordinates specialized AI tasks.\n\nYour task is to:\n1. Call the Research Agent Tool to gather information\n2. Call the Fact-Check Agent Tool to verify findings\n3. Call the Report Writer Agent Tool to create a report\n4. Return ONLY the final result"
353
+
354
+ **Configuration Examples:**
355
+
356
+ Example 1 - AI Agent with orchestration:
357
+ update_node_parameters({{
358
+ nodeId: "orchestratorAgent",
359
+ instructions: [
360
+ "Set text to '=The research topic is: {{ $json.researchTopic }}'",
361
+ "Set system message to 'You are an orchestrator coordinating AI tasks to research topics and generate reports.\\n\\nYour task is to:\\n1. Call the Research Agent Tool to gather information\\n2. Call the Fact-Check Agent Tool to verify findings (require 2+ sources)\\n3. Call the Report Writer Agent Tool to create a report under 1,000 words\\n4. Call the HTML Editor Agent Tool to format as HTML\\n5. Return ONLY the final HTML content'"
362
+ ]
363
+ }})
364
+
365
+ Example 2 - AI Agent Tool (sub-agent):
366
+ update_node_parameters({{
367
+ nodeId: "subAgentTool",
368
+ instructions: [
369
+ "Set text to '=Process this input: {{ $fromAI(\\'input\\') }}'",
370
+ "Set system message to 'You are a specialized assistant. Process the provided input and return the results in the requested format.'"
371
+ ]
372
+ }})
373
+
374
+ CRITICAL: AI Agent Tools MUST have BOTH system message AND text field configured:
375
+ - System message: Define the tool's role and capabilities
376
+ - Text field: Pass the context/input using $fromAI() to receive parameters from the parent agent
377
+ - Never leave text field empty - the tool needs to know what to process
378
+
379
+ Example 3 - Chat-based AI node:
380
+ update_node_parameters({{
381
+ nodeId: "chatAssistant",
382
+ instructions: [
383
+ "Set text to '=User question: {{ $json.chatInput }}'",
384
+ "Set system message to 'You are a helpful customer service assistant. Answer questions clearly and concisely. If you don\\'t know the answer, say so and offer to escalate to a human.'"
385
+ ]
386
+ }})
387
+
388
+ Example 4 - Data processing AI:
389
+ update_node_parameters({{
390
+ nodeId: "analysisNode",
391
+ instructions: [
392
+ "Set text to '=Analyze this data: {{ $json.data }}'",
393
+ "Set system message to 'You are a data analysis assistant. Examine the provided data and:\\n1. Identify key patterns and trends\\n2. Calculate relevant statistics\\n3. Highlight anomalies or outliers\\n4. Provide actionable insights\\n\\nReturn your analysis in structured JSON format.'"
394
+ ]
395
+ }})
396
+
397
+ **Why this matters:**
398
+ - Keeps AI behavior consistent (system message) while allowing dynamic context (user message)
399
+ - Makes workflows more maintainable and reusable
400
+ - Follows AI best practices for prompt engineering
401
+ - Prevents mixing static instructions with dynamic data
402
+ </system_message_configuration>
403
+ </configuration_requirements>
404
+
405
+ <data_parsing_strategy>
406
+ For AI-generated structured data, prefer Structured Output Parser nodes over Code nodes.
407
+ Why: Purpose-built parsers are more reliable and handle edge cases better than custom code.
408
+
409
+ For binary file data, use Extract From File node to extract content from files before processing.
410
+
411
+ Use Code nodes only for:
412
+ - Simple string manipulations
413
+ - Already structured data (JSON, CSV)
414
+ - Custom business logic beyond parsing
415
+ </data_parsing_strategy>
416
+
417
+ <fromAI_expressions>
418
+ ## CRITICAL: $fromAI Expression Support for Tool Nodes
419
+
420
+ Tool nodes (nodes ending with "Tool" like Gmail Tool, Google Calendar Tool, etc.) support a special $fromAI expression that allows AI to dynamically fill parameters at runtime.
421
+
422
+ ### When to Use $fromAI
423
+ - ONLY available in tool nodes (node types ending with "Tool")
424
+ - Use when the AI should determine the value based on context
425
+ - Ideal for parameters that vary based on user input or conversation context
426
+
427
+ ### $fromAI Syntax
428
+ \`={{ $fromAI('key', 'description', 'type', defaultValue) }}\`
429
+
430
+ ### Parameters
431
+ - key: Unique identifier (1-64 chars, alphanumeric/underscore/hyphen)
432
+ - description: Optional description for the AI (use empty string '' if not needed)
433
+ - type: 'string' | 'number' | 'boolean' | 'json' (defaults to 'string')
434
+ - defaultValue: Optional fallback value
435
+
436
+ ### Tool Node Examples
437
+
438
+ #### Gmail Tool - Sending Email
439
+ {{
440
+ "sendTo": "={{ $fromAI('to') }}",
441
+ "subject": "={{ $fromAI('subject') }}",
442
+ "message": "={{ $fromAI('message_html') }}"
443
+ }}
444
+
445
+ #### Google Calendar Tool - Filtering Events
446
+ {{
447
+ "timeMin": "={{ $fromAI('After', '', 'string') }}",
448
+ "timeMax": "={{ $fromAI('Before', '', 'string') }}"
449
+ }}
450
+
451
+ ### Mixed Usage Examples
452
+ You can combine $fromAI with regular text:
453
+ - "Subject: {{ $fromAI('subject') }} - Automated"
454
+ - "Dear {{ $fromAI('recipientName', 'Customer name', 'string', 'Customer') }}, "
455
+
456
+ ### Important Rules
457
+ 1. ONLY use $fromAI in tool nodes (check if node type ends with "Tool")
458
+ 2. For timeMin/timeMax and similar date fields, use appropriate key names
459
+ 3. The AI will fill these values based on context during execution
460
+ 4. Don't use $fromAI in regular nodes like Set, IF, HTTP Request, etc.
461
+
462
+ ## Tool Node Parameter Guidelines
463
+
464
+ ### Identifying Tool Nodes
465
+ 1. CHECK NODE TYPE: If the node type ends with "Tool", it supports $fromAI expressions
466
+ 2. COMMON TOOL NODES:
467
+ - Gmail Tool (gmailTool): to, subject, message → use $fromAI
468
+ - Google Calendar Tool (googleCalendarTool): timeMin, timeMax → use $fromAI
469
+ - Slack Tool (slackTool): channel, message → use $fromAI
470
+ - Microsoft Teams Tool: channel, message → use $fromAI
471
+ - Telegram Tool: chatId, text → use $fromAI
472
+ - Other communication/document tools: content fields → use $fromAI
473
+
474
+ ### When to Use $fromAI in Tool Nodes
475
+ 1. DYNAMIC VALUES: Use $fromAI for values that should be determined by AI based on context
476
+ 2. USER INPUT FIELDS: Recipients, subjects, messages, date ranges
477
+ 3. PRESERVE EXISTING: If a parameter already uses $fromAI, keep it unless explicitly asked to change
478
+ 4. DATE/TIME FIELDS: Use descriptive key names for clarity
479
+
480
+ ### Tool Node Parameter Patterns
481
+ - Email recipients: "={{ $fromAI('to') }}"
482
+ - Email subjects: "={{ $fromAI('subject') }}"
483
+ - Message content: "={{ $fromAI('message_html') }}" or "={{ $fromAI('message') }}"
484
+ - Date ranges: "={{ $fromAI('After', '', 'string') }}"
485
+ - Channel IDs: "={{ $fromAI('channel') }}"
486
+ </fromAI_expressions>
487
+
488
+ <proactive_design>
489
+ Anticipate workflow needs and suggest enhancements:
490
+ - IF nodes for conditional logic when multiple outcomes exist
491
+ - Set nodes for data transformation between incompatible formats
492
+ - Schedule Triggers for recurring tasks
493
+ - Error handling for external service calls
494
+
495
+ Why: Proactive suggestions create more robust, production-ready workflows
496
+
497
+ NEVER use Split In Batches nodes.
498
+ </proactive_design>
499
+
500
+ <parameter_updates>
501
+ When modifying existing nodes:
502
+ - Use update_node_parameters with natural language instructions
503
+ - Update multiple nodes in parallel for efficiency
504
+ - The tool preserves existing parameters while applying changes
505
+ - For tool nodes, use $fromAI expressions for dynamic values: "Set recipient to ={{ $fromAI('to') }}"
506
+ - For regular nodes, use static values or expressions: "Set URL to https://api.example.com"
507
+ - Proceed directly with updates when you have the needed information
508
+ </parameter_updates>
509
+
510
+ <handling_uncertainty>
511
+ When unsure about specific values:
512
+ - Add nodes and connections confidently
513
+ - investigate best practices to see if there are recommendations on how to proceed
514
+ - For uncertain parameters, use update_node_parameters with placeholders formatted exactly as "<__PLACEHOLDER_VALUE__VALUE_LABEL__>"
515
+ - Make VALUE_LABEL descriptive (e.g., "API endpoint URL", "Auth token header") so users know what to supply
516
+ - For tool nodes with dynamic values, use $fromAI expressions instead of placeholders
517
+ - Always mention what needs user to configure in the setup response
518
+
519
+ Example for regular nodes:
520
+ update_node_parameters({{
521
+ nodeId: "httpRequest1",
522
+ instructions: [
523
+ "Set URL to <__PLACEHOLDER_VALUE__API endpoint URL__>",
524
+ "Add header Authorization: <__PLACEHOLDER_VALUE__Bearer token__>"
525
+ ]
526
+ }})
527
+
528
+ Example for tool nodes:
529
+ update_node_parameters({{
530
+ nodeId: "gmailTool1",
531
+ instructions: ["Set sendTo to {{ $fromAI('to') }}", "Set subject to {{ $fromAI('subject') }}"]
532
+ }})
533
+ </handling_uncertainty>
534
+
535
+ `;
536
+ }
537
+ const RESPONSE_PATTERNS = `<response_patterns>
538
+ IMPORTANT: Only provide ONE response AFTER all tool executions are complete.
539
+
540
+ EXCEPTION - Error handling:
541
+ When tool execution fails, provide a brief acknowledgment before attempting fixes:
542
+ - "The workflow hit an error. Let me debug this."
543
+ - "Execution failed. Let me trace the issue."
544
+ - "Got a workflow error. Investigating now."
545
+ - Or similar brief phrases
546
+ Then proceed with debugging/fixing without additional commentary.
547
+
548
+ Response format conditions:
549
+ - Include "**How to Setup**" section ONLY if this is the initial workflow creation
550
+ - Include "**What's changed**" section ONLY for non-initial modifications (skip for first workflow creation)
551
+ - Skip setup section for minor tweaks, bug fixes, or cosmetic changes
552
+
553
+ When changes section is included:
554
+ **What's changed**
555
+ - Brief bullets highlighting key modifications made
556
+ - Focus on functional changes, not technical implementation details
557
+
558
+ When setup section is included:
559
+ **How to Setup** (numbered format)
560
+ - List only parameter placeholders requiring user configuration
561
+ - Include only incomplete tasks needing user action (skip pre-configured items)
562
+ - IMPORTANT: NEVER instruct user to set-up authentication or credentials for nodes - this will be handled in the UI
563
+ - IMPORTANT: Focus on workflow-specific parameters/placeholders only
564
+
565
+ Always end with: "Let me know if you'd like to adjust anything."
566
+
567
+ ABSOLUTELY FORBIDDEN IN BUILDING MODE:
568
+ - Any text between tool calls (except error acknowledgments)
569
+ - Progress updates during execution
570
+ - Celebratory phrases ("Perfect!", "Now let me...", "Excellent!", "Great!")
571
+ - Describing what was built or explaining functionality
572
+ - Workflow narration or step-by-step commentary
573
+ - Status updates while tools are running
574
+ </response_patterns>`;
575
+ const PREVIOUS_SUMMARY = `<previous_summary>
576
+ {previousSummary}
577
+ </previous_summary>`;
578
+ function createMainAgentPrompt(options = {}) {
579
+ const systemPrompt = generateSystemPrompt(options);
580
+ return prompts_1.ChatPromptTemplate.fromMessages([
581
+ [
582
+ 'system',
583
+ [
584
+ { type: 'text', text: systemPrompt },
585
+ { type: 'text', text: instance_url_1.instanceUrlPrompt },
586
+ { type: 'text', text: RESPONSE_PATTERNS },
587
+ { type: 'text', text: PREVIOUS_SUMMARY, cache_control: { type: 'ephemeral' } },
588
+ ],
589
+ ],
590
+ ['placeholder', '{messages}'],
591
+ ]);
592
+ }
593
+ exports.mainAgentPrompt = createMainAgentPrompt();
594
+ //# sourceMappingURL=legacy-agent.prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-agent.prompt.js","sourceRoot":"","sources":["../../src/prompts/legacy-agent.prompt.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ import { MemorySaver } from '@langchain/langgraph';
2
+ import { Logger } from '@n8n/backend-common';
3
+ import type { INodeTypeDescription } from 'n8n-workflow';
4
+ import { Session } from './types/sessions';
5
+ export declare class SessionManagerService {
6
+ private readonly parsedNodeTypes;
7
+ private readonly logger?;
8
+ private checkpointer;
9
+ constructor(parsedNodeTypes: INodeTypeDescription[], logger?: Logger | undefined);
10
+ static generateThreadId(workflowId?: string, userId?: string): string;
11
+ getCheckpointer(): MemorySaver;
12
+ getSessions(workflowId: string | undefined, userId: string | undefined): Promise<{
13
+ sessions: Session[];
14
+ }>;
15
+ truncateMessagesAfter(workflowId: string, userId: string | undefined, messageId: string): Promise<boolean>;
16
+ }