n8n 2.4.4 → 2.5.1

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 (396) hide show
  1. package/dist/active-executions.js +1 -0
  2. package/dist/active-executions.js.map +1 -1
  3. package/dist/auth/auth.service.js +2 -1
  4. package/dist/auth/auth.service.js.map +1 -1
  5. package/dist/build.tsbuildinfo +1 -1
  6. package/dist/chat/chat-service.d.ts +2 -1
  7. package/dist/chat/chat-service.js +33 -11
  8. package/dist/chat/chat-service.js.map +1 -1
  9. package/dist/chat/utils.d.ts +1 -1
  10. package/dist/chat/utils.js +5 -0
  11. package/dist/chat/utils.js.map +1 -1
  12. package/dist/commands/base-command.js +2 -0
  13. package/dist/commands/base-command.js.map +1 -1
  14. package/dist/commands/export/credentials.d.ts +2 -2
  15. package/dist/commands/export/workflow.d.ts +2 -2
  16. package/dist/commands/import/entities.d.ts +3 -0
  17. package/dist/commands/import/entities.js +11 -1
  18. package/dist/commands/import/entities.js.map +1 -1
  19. package/dist/commands/start.js +1 -4
  20. package/dist/commands/start.js.map +1 -1
  21. package/dist/commands/webhook.js +2 -0
  22. package/dist/commands/webhook.js.map +1 -1
  23. package/dist/commands/worker.js +1 -0
  24. package/dist/commands/worker.js.map +1 -1
  25. package/dist/config/index.js +0 -1
  26. package/dist/config/index.js.map +1 -1
  27. package/dist/controller.registry.js +6 -0
  28. package/dist/controller.registry.js.map +1 -1
  29. package/dist/controllers/ai.controller.d.ts +1 -2
  30. package/dist/controllers/ai.controller.js +0 -18
  31. package/dist/controllers/ai.controller.js.map +1 -1
  32. package/dist/controllers/auth.controller.js +2 -1
  33. package/dist/controllers/auth.controller.js.map +1 -1
  34. package/dist/controllers/e2e.controller.d.ts +3 -3
  35. package/dist/controllers/e2e.controller.js +10 -8
  36. package/dist/controllers/e2e.controller.js.map +1 -1
  37. package/dist/controllers/me.controller.js +13 -15
  38. package/dist/controllers/me.controller.js.map +1 -1
  39. package/dist/controllers/node-types.controller.d.ts +2 -0
  40. package/dist/controllers/node-types.controller.js +40 -22
  41. package/dist/controllers/node-types.controller.js.map +1 -1
  42. package/dist/controllers/orchestration.controller.d.ts +2 -1
  43. package/dist/controllers/orchestration.controller.js +3 -3
  44. package/dist/controllers/orchestration.controller.js.map +1 -1
  45. package/dist/credentials-helper.js +3 -1
  46. package/dist/credentials-helper.js.map +1 -1
  47. package/dist/deprecation/deprecation.service.js +5 -0
  48. package/dist/deprecation/deprecation.service.js.map +1 -1
  49. package/dist/eventbus/message-event-bus/message-event-bus.d.ts +2 -21
  50. package/dist/eventbus/message-event-bus/message-event-bus.js +1 -110
  51. package/dist/eventbus/message-event-bus/message-event-bus.js.map +1 -1
  52. package/dist/events/maps/relay.event-map.d.ts +6 -0
  53. package/dist/events/relays/telemetry.event-relay.d.ts +1 -0
  54. package/dist/events/relays/telemetry.event-relay.js +18 -4
  55. package/dist/events/relays/telemetry.event-relay.js.map +1 -1
  56. package/dist/events/relays/workflow-failure-notification.event-relay.d.ts +13 -0
  57. package/dist/events/relays/workflow-failure-notification.event-relay.js +78 -0
  58. package/dist/events/relays/workflow-failure-notification.event-relay.js.map +1 -0
  59. package/dist/executions/execution-data/types.d.ts +17 -0
  60. package/dist/executions/execution-data/types.js.map +1 -0
  61. package/dist/executions/{execution-data.service.d.ts → failed-run-factory.d.ts} +1 -1
  62. package/dist/executions/{execution-data.service.js → failed-run-factory.js} +6 -6
  63. package/dist/executions/failed-run-factory.js.map +1 -0
  64. package/dist/license/license.controller.js +6 -1
  65. package/dist/license/license.controller.js.map +1 -1
  66. package/dist/license/license.service.d.ts +2 -1
  67. package/dist/license/license.service.js +10 -2
  68. package/dist/license/license.service.js.map +1 -1
  69. package/dist/license.d.ts +2 -1
  70. package/dist/license.js +2 -2
  71. package/dist/license.js.map +1 -1
  72. package/dist/load-nodes-and-credentials.d.ts +1 -0
  73. package/dist/load-nodes-and-credentials.js +7 -0
  74. package/dist/load-nodes-and-credentials.js.map +1 -1
  75. package/dist/mfa/mfa.service.d.ts +5 -3
  76. package/dist/mfa/mfa.service.js +15 -10
  77. package/dist/mfa/mfa.service.js.map +1 -1
  78. package/dist/modules/breaking-changes/breaking-changes.module.js +1 -1
  79. package/dist/modules/breaking-changes/breaking-changes.module.js.map +1 -1
  80. package/dist/modules/breaking-changes/breaking-changes.service.d.ts +4 -3
  81. package/dist/modules/breaking-changes/breaking-changes.service.js +25 -6
  82. package/dist/modules/breaking-changes/breaking-changes.service.js.map +1 -1
  83. package/dist/modules/breaking-changes/rules/index.d.ts +1 -1
  84. package/dist/modules/breaking-changes/rules/v2/index.d.ts +2 -3
  85. package/dist/modules/breaking-changes/rules/v2/index.js +0 -4
  86. package/dist/modules/breaking-changes/rules/v2/index.js.map +1 -1
  87. package/dist/modules/chat-hub/chat-hub-agent.service.d.ts +2 -2
  88. package/dist/modules/chat-hub/chat-hub-agent.service.js +2 -2
  89. package/dist/modules/chat-hub/chat-hub-agent.service.js.map +1 -1
  90. package/dist/modules/chat-hub/chat-hub-extractor.d.ts +22 -0
  91. package/dist/modules/chat-hub/chat-hub-extractor.js +64 -0
  92. package/dist/modules/chat-hub/chat-hub-extractor.js.map +1 -0
  93. package/dist/modules/chat-hub/chat-hub-message.entity.js +1 -1
  94. package/dist/modules/chat-hub/chat-hub-message.entity.js.map +1 -1
  95. package/dist/modules/chat-hub/chat-hub-session.entity.js +1 -1
  96. package/dist/modules/chat-hub/chat-hub-session.entity.js.map +1 -1
  97. package/dist/modules/chat-hub/chat-hub-workflow.service.d.ts +1 -1
  98. package/dist/modules/chat-hub/chat-hub-workflow.service.js +2 -2
  99. package/dist/modules/chat-hub/chat-hub-workflow.service.js.map +1 -1
  100. package/dist/modules/chat-hub/chat-hub.constants.d.ts +2 -0
  101. package/dist/modules/chat-hub/chat-hub.constants.js +8 -1
  102. package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
  103. package/dist/modules/chat-hub/chat-hub.controller.js +17 -5
  104. package/dist/modules/chat-hub/chat-hub.controller.js.map +1 -1
  105. package/dist/modules/chat-hub/chat-hub.service.d.ts +16 -3
  106. package/dist/modules/chat-hub/chat-hub.service.js +290 -56
  107. package/dist/modules/chat-hub/chat-hub.service.js.map +1 -1
  108. package/dist/modules/chat-hub/chat-hub.types.d.ts +8 -2
  109. package/dist/modules/chat-hub/chat-hub.types.js.map +1 -1
  110. package/dist/modules/community-packages/community-node-types.service.js +2 -5
  111. package/dist/modules/community-packages/community-node-types.service.js.map +1 -1
  112. package/dist/modules/community-packages/community-packages.module.d.ts +1 -0
  113. package/dist/modules/community-packages/community-packages.module.js +3 -0
  114. package/dist/modules/community-packages/community-packages.module.js.map +1 -1
  115. package/dist/modules/community-packages/community-packages.service.js +4 -0
  116. package/dist/modules/community-packages/community-packages.service.js.map +1 -1
  117. package/dist/modules/data-table/data-table-file-cleanup.service.d.ts +3 -1
  118. package/dist/modules/data-table/data-table-file-cleanup.service.js +7 -2
  119. package/dist/modules/data-table/data-table-file-cleanup.service.js.map +1 -1
  120. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.d.ts +4 -0
  121. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js +32 -0
  122. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js.map +1 -0
  123. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.d.ts +9 -2
  124. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js +63 -7
  125. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js.map +1 -1
  126. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.d.ts +12 -0
  127. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js +70 -0
  128. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js.map +1 -0
  129. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.d.ts +5 -2
  130. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js +17 -3
  131. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js.map +1 -1
  132. package/dist/modules/external-secrets.ee/external-secrets.config.d.ts +1 -0
  133. package/dist/modules/external-secrets.ee/external-secrets.config.js +5 -0
  134. package/dist/modules/external-secrets.ee/external-secrets.config.js.map +1 -1
  135. package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.d.ts +6 -0
  136. package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.js +29 -0
  137. package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.js.map +1 -0
  138. package/dist/modules/log-streaming.ee/database/entities/index.d.ts +1 -0
  139. package/dist/modules/log-streaming.ee/database/entities/index.js +6 -0
  140. package/dist/modules/log-streaming.ee/database/entities/index.js.map +1 -0
  141. package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.d.ts +5 -0
  142. package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.js +26 -0
  143. package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.js.map +1 -0
  144. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-from-db.d.ts +2 -2
  145. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.js.map +1 -0
  146. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-sentry.ee.d.ts +1 -1
  147. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-sentry.ee.js +3 -4
  148. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.js.map +1 -0
  149. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-syslog.ee.d.ts +1 -1
  150. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-syslog.ee.js +1 -1
  151. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.js.map +1 -0
  152. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-webhook.ee.d.ts +2 -2
  153. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-webhook.ee.js +3 -3
  154. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.js.map +1 -0
  155. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination.ee.d.ts +6 -12
  156. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination.ee.js +9 -49
  157. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination.ee.js.map +1 -0
  158. package/dist/modules/log-streaming.ee/log-streaming-destination.service.d.ts +32 -0
  159. package/dist/modules/log-streaming.ee/log-streaming-destination.service.js +176 -0
  160. package/dist/modules/log-streaming.ee/log-streaming-destination.service.js.map +1 -0
  161. package/dist/{eventbus/event-bus.controller.d.ts → modules/log-streaming.ee/log-streaming.controller.d.ts} +5 -3
  162. package/dist/{eventbus/event-bus.controller.js → modules/log-streaming.ee/log-streaming.controller.js} +19 -18
  163. package/dist/modules/log-streaming.ee/log-streaming.controller.js.map +1 -0
  164. package/dist/modules/log-streaming.ee/log-streaming.module.d.ts +5 -0
  165. package/dist/modules/log-streaming.ee/log-streaming.module.js +67 -0
  166. package/dist/modules/log-streaming.ee/log-streaming.module.js.map +1 -0
  167. package/dist/modules/mcp/mcp.errors.d.ts +5 -0
  168. package/dist/modules/mcp/mcp.errors.js +9 -1
  169. package/dist/modules/mcp/mcp.errors.js.map +1 -1
  170. package/dist/modules/mcp/mcp.service.d.ts +7 -2
  171. package/dist/modules/mcp/mcp.service.js +13 -4
  172. package/dist/modules/mcp/mcp.service.js.map +1 -1
  173. package/dist/modules/mcp/mcp.types.d.ts +9 -5
  174. package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +3 -3
  175. package/dist/modules/mcp/tools/execute-workflow.tool.js +34 -10
  176. package/dist/modules/mcp/tools/execute-workflow.tool.js.map +1 -1
  177. package/dist/modules/mcp/tools/get-workflow-details.tool.d.ts +4 -2
  178. package/dist/modules/mcp/tools/get-workflow-details.tool.js +9 -3
  179. package/dist/modules/mcp/tools/get-workflow-details.tool.js.map +1 -1
  180. package/dist/modules/mcp/tools/schemas.d.ts +10 -0
  181. package/dist/modules/mcp/tools/schemas.js +2 -0
  182. package/dist/modules/mcp/tools/schemas.js.map +1 -1
  183. package/dist/modules/mcp/tools/search-workflows.tool.js +25 -14
  184. package/dist/modules/mcp/tools/search-workflows.tool.js.map +1 -1
  185. package/dist/modules/provisioning.ee/provisioning.module.js +5 -1
  186. package/dist/modules/provisioning.ee/provisioning.module.js.map +1 -1
  187. package/dist/modules/source-control.ee/source-control-git.service.ee.d.ts +1 -0
  188. package/dist/modules/source-control.ee/source-control-git.service.ee.js +40 -3
  189. package/dist/modules/source-control.ee/source-control-git.service.ee.js.map +1 -1
  190. package/dist/modules/source-control.ee/source-control-preferences.service.ee.d.ts +3 -1
  191. package/dist/modules/source-control.ee/source-control-preferences.service.ee.js +61 -11
  192. package/dist/modules/source-control.ee/source-control-preferences.service.ee.js.map +1 -1
  193. package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +1 -1
  194. package/dist/modules/source-control.ee/source-control.controller.ee.js +35 -5
  195. package/dist/modules/source-control.ee/source-control.controller.ee.js.map +1 -1
  196. package/dist/modules/source-control.ee/source-control.module.js +5 -1
  197. package/dist/modules/source-control.ee/source-control.module.js.map +1 -1
  198. package/dist/modules/source-control.ee/source-control.service.ee.d.ts +4 -0
  199. package/dist/modules/source-control.ee/source-control.service.ee.js +77 -5
  200. package/dist/modules/source-control.ee/source-control.service.ee.js.map +1 -1
  201. package/dist/modules/sso-oidc/constants.js.map +1 -0
  202. package/dist/{sso.ee/oidc/routes → modules/sso-oidc}/oidc.controller.ee.d.ts +4 -4
  203. package/dist/{sso.ee/oidc/routes → modules/sso-oidc}/oidc.controller.ee.js +6 -6
  204. package/dist/modules/sso-oidc/oidc.controller.ee.js.map +1 -0
  205. package/dist/{sso.ee/oidc → modules/sso-oidc}/oidc.service.ee.js +2 -2
  206. package/dist/modules/sso-oidc/oidc.service.ee.js.map +1 -0
  207. package/dist/modules/sso-oidc/sso-oidc.module.d.ts +4 -0
  208. package/dist/modules/sso-oidc/sso-oidc.module.js +56 -0
  209. package/dist/modules/sso-oidc/sso-oidc.module.js.map +1 -0
  210. package/dist/modules/sso-saml/constants.js.map +1 -0
  211. package/dist/modules/sso-saml/errors/invalid-saml-metadata-url.error.js.map +1 -0
  212. package/dist/modules/sso-saml/errors/invalid-saml-metadata.error.js.map +1 -0
  213. package/dist/{sso.ee/saml → modules/sso-saml}/middleware/saml-enabled-middleware.js +3 -3
  214. package/dist/modules/sso-saml/middleware/saml-enabled-middleware.js.map +1 -0
  215. package/dist/{sso.ee/saml → modules/sso-saml}/saml-helpers.d.ts +0 -4
  216. package/dist/{sso.ee/saml → modules/sso-saml}/saml-helpers.js +1 -18
  217. package/dist/modules/sso-saml/saml-helpers.js.map +1 -0
  218. package/dist/modules/sso-saml/saml-validator.js.map +1 -0
  219. package/dist/{sso.ee/saml/routes → modules/sso-saml}/saml.controller.ee.d.ts +5 -5
  220. package/dist/{sso.ee/saml/routes → modules/sso-saml}/saml.controller.ee.js +12 -11
  221. package/dist/modules/sso-saml/saml.controller.ee.js.map +1 -0
  222. package/dist/{sso.ee/saml → modules/sso-saml}/saml.service.ee.js +12 -12
  223. package/dist/modules/sso-saml/saml.service.ee.js.map +1 -0
  224. package/dist/modules/sso-saml/schema/metadata-exchange.xsd.js.map +1 -0
  225. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.js.map +1 -0
  226. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.js.map +1 -0
  227. package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-assertion-2.0.xsd.js.map +1 -1
  228. package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-metadata-2.0.xsd.js.map +1 -1
  229. package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-protocol-2.0.xsd.js.map +1 -1
  230. package/dist/modules/sso-saml/schema/ws-addr.xsd.js.map +1 -0
  231. package/dist/modules/sso-saml/schema/ws-authorization.xsd.js.map +1 -0
  232. package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-federation.xsd.js.map +1 -1
  233. package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-securitypolicy-1.2.xsd.js.map +1 -1
  234. package/dist/modules/sso-saml/schema/xenc-schema.xsd.js.map +1 -0
  235. package/dist/modules/sso-saml/schema/xml.xsd.js.map +1 -0
  236. package/dist/{sso.ee/saml → modules/sso-saml}/schema/xmldsig-core-schema.xsd.js.map +1 -1
  237. package/dist/modules/sso-saml/service-provider.ee.js.map +1 -0
  238. package/dist/modules/sso-saml/sso-saml.module.d.ts +4 -0
  239. package/dist/modules/sso-saml/sso-saml.module.js +56 -0
  240. package/dist/modules/sso-saml/sso-saml.module.js.map +1 -0
  241. package/dist/modules/sso-saml/types.js +3 -0
  242. package/dist/{sso.ee/saml → modules/sso-saml}/types.js.map +1 -1
  243. package/dist/modules/sso-saml/views/init-sso-post.js.map +1 -0
  244. package/dist/modules/workflow-index/workflow-index.service.js +8 -0
  245. package/dist/modules/workflow-index/workflow-index.service.js.map +1 -1
  246. package/dist/node-types.d.ts +1 -0
  247. package/dist/node-types.js +17 -0
  248. package/dist/node-types.js.map +1 -1
  249. package/dist/scaling/constants.d.ts +2 -2
  250. package/dist/scaling/pubsub/pubsub.event-map.d.ts +7 -2
  251. package/dist/scaling/pubsub/pubsub.types.d.ts +2 -1
  252. package/dist/scaling/worker-status.service.ee.d.ts +7 -3
  253. package/dist/scaling/worker-status.service.ee.js +13 -7
  254. package/dist/scaling/worker-status.service.ee.js.map +1 -1
  255. package/dist/server.d.ts +0 -1
  256. package/dist/server.js +5 -22
  257. package/dist/server.js.map +1 -1
  258. package/dist/services/ai-workflow-builder.service.d.ts +2 -3
  259. package/dist/services/ai-workflow-builder.service.js +36 -36
  260. package/dist/services/ai-workflow-builder.service.js.map +1 -1
  261. package/dist/services/cors-service.d.ts +7 -0
  262. package/dist/services/cors-service.js +51 -0
  263. package/dist/services/cors-service.js.map +1 -0
  264. package/dist/services/frontend.service.d.ts +3 -1
  265. package/dist/services/frontend.service.js +19 -4
  266. package/dist/services/frontend.service.js.map +1 -1
  267. package/dist/services/import.service.d.ts +2 -4
  268. package/dist/services/import.service.js +11 -11
  269. package/dist/services/import.service.js.map +1 -1
  270. package/dist/services/project.service.ee.d.ts +1 -3
  271. package/dist/services/project.service.ee.js +4 -12
  272. package/dist/services/project.service.ee.js.map +1 -1
  273. package/dist/services/pruning/workflow-history-compaction.service.d.ts +11 -6
  274. package/dist/services/pruning/workflow-history-compaction.service.js +72 -25
  275. package/dist/services/pruning/workflow-history-compaction.service.js.map +1 -1
  276. package/dist/services/public-api-key.service.js +2 -1
  277. package/dist/services/public-api-key.service.js.map +1 -1
  278. package/dist/services/role-cache.service.d.ts +2 -1
  279. package/dist/services/role-cache.service.js +4 -4
  280. package/dist/services/role-cache.service.js.map +1 -1
  281. package/dist/services/role.service.d.ts +2 -1
  282. package/dist/services/role.service.js +3 -3
  283. package/dist/services/role.service.js.map +1 -1
  284. package/dist/services/user.service.d.ts +5 -3
  285. package/dist/services/user.service.js +15 -1
  286. package/dist/services/user.service.js.map +1 -1
  287. package/dist/services/workflow-statistics.service.d.ts +4 -2
  288. package/dist/services/workflow-statistics.service.js +35 -4
  289. package/dist/services/workflow-statistics.service.js.map +1 -1
  290. package/dist/sso.ee/sso-helpers.d.ts +4 -0
  291. package/dist/sso.ee/sso-helpers.js +17 -1
  292. package/dist/sso.ee/sso-helpers.js.map +1 -1
  293. package/dist/user-management/email/templates/workflow-failure.handlebars +211 -0
  294. package/dist/user-management/email/user-management-mailer.d.ts +7 -1
  295. package/dist/user-management/email/user-management-mailer.js +19 -0
  296. package/dist/user-management/email/user-management-mailer.js.map +1 -1
  297. package/dist/workflow-execute-additional-data.js +2 -2
  298. package/dist/workflow-execute-additional-data.js.map +1 -1
  299. package/dist/workflow-helpers.d.ts +2 -1
  300. package/dist/workflow-helpers.js +21 -0
  301. package/dist/workflow-helpers.js.map +1 -1
  302. package/dist/workflow-runner.d.ts +3 -3
  303. package/dist/workflow-runner.js +5 -5
  304. package/dist/workflow-runner.js.map +1 -1
  305. package/dist/workflows/workflow-execution.service.d.ts +4 -4
  306. package/dist/workflows/workflow-execution.service.js +7 -7
  307. package/dist/workflows/workflow-execution.service.js.map +1 -1
  308. package/dist/workflows/workflow-finder.service.d.ts +0 -1
  309. package/dist/workflows/workflow-finder.service.js +2 -2
  310. package/dist/workflows/workflow-finder.service.js.map +1 -1
  311. package/dist/workflows/workflow.service.js +10 -17
  312. package/dist/workflows/workflow.service.js.map +1 -1
  313. package/dist/workflows/workflows.controller.d.ts +0 -8
  314. package/package.json +16 -16
  315. package/dist/eventbus/event-bus.controller.js.map +0 -1
  316. package/dist/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.js.map +0 -1
  317. package/dist/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee.js.map +0 -1
  318. package/dist/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.js.map +0 -1
  319. package/dist/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.js.map +0 -1
  320. package/dist/eventbus/message-event-bus-destination/message-event-bus-destination.ee.js.map +0 -1
  321. package/dist/executions/execution-data.service.js.map +0 -1
  322. package/dist/executions/legacy-sqlite-execution-recovery.service.d.ts +0 -11
  323. package/dist/executions/legacy-sqlite-execution-recovery.service.js +0 -48
  324. package/dist/executions/legacy-sqlite-execution-recovery.service.js.map +0 -1
  325. package/dist/modules/breaking-changes/rules/v2/git-node-bare-repos.rule.d.ts +0 -10
  326. package/dist/modules/breaking-changes/rules/v2/git-node-bare-repos.rule.js +0 -66
  327. package/dist/modules/breaking-changes/rules/v2/git-node-bare-repos.rule.js.map +0 -1
  328. package/dist/modules/breaking-changes/rules/v2/sqlite-legacy-driver.rule.d.ts +0 -9
  329. package/dist/modules/breaking-changes/rules/v2/sqlite-legacy-driver.rule.js +0 -75
  330. package/dist/modules/breaking-changes/rules/v2/sqlite-legacy-driver.rule.js.map +0 -1
  331. package/dist/sso.ee/oidc/constants.js.map +0 -1
  332. package/dist/sso.ee/oidc/oidc.service.ee.js.map +0 -1
  333. package/dist/sso.ee/oidc/routes/oidc.controller.ee.js.map +0 -1
  334. package/dist/sso.ee/saml/constants.js.map +0 -1
  335. package/dist/sso.ee/saml/errors/invalid-saml-metadata-url.error.js.map +0 -1
  336. package/dist/sso.ee/saml/errors/invalid-saml-metadata.error.js.map +0 -1
  337. package/dist/sso.ee/saml/middleware/saml-enabled-middleware.js.map +0 -1
  338. package/dist/sso.ee/saml/routes/saml.controller.ee.js.map +0 -1
  339. package/dist/sso.ee/saml/saml-helpers.js.map +0 -1
  340. package/dist/sso.ee/saml/saml-validator.js.map +0 -1
  341. package/dist/sso.ee/saml/saml.service.ee.js.map +0 -1
  342. package/dist/sso.ee/saml/schema/metadata-exchange.xsd.js.map +0 -1
  343. package/dist/sso.ee/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.js.map +0 -1
  344. package/dist/sso.ee/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.js.map +0 -1
  345. package/dist/sso.ee/saml/schema/ws-addr.xsd.js.map +0 -1
  346. package/dist/sso.ee/saml/schema/ws-authorization.xsd.js.map +0 -1
  347. package/dist/sso.ee/saml/schema/xenc-schema.xsd.js.map +0 -1
  348. package/dist/sso.ee/saml/schema/xml.xsd.js.map +0 -1
  349. package/dist/sso.ee/saml/service-provider.ee.js.map +0 -1
  350. package/dist/sso.ee/saml/views/init-sso-post.js.map +0 -1
  351. package/dist/{sso.ee/saml → executions/execution-data}/types.js +0 -0
  352. package/dist/{eventbus/message-event-bus-destination → modules/log-streaming.ee/destinations}/message-event-bus-destination-from-db.js +0 -0
  353. package/dist/{sso.ee/oidc → modules/sso-oidc}/constants.d.ts +0 -0
  354. package/dist/{sso.ee/oidc → modules/sso-oidc}/constants.js +0 -0
  355. package/dist/{sso.ee/oidc → modules/sso-oidc}/oidc.service.ee.d.ts +0 -0
  356. package/dist/{sso.ee/saml → modules/sso-saml}/constants.d.ts +0 -0
  357. package/dist/{sso.ee/saml → modules/sso-saml}/constants.js +0 -0
  358. package/dist/{sso.ee/saml → modules/sso-saml}/errors/invalid-saml-metadata-url.error.d.ts +0 -0
  359. package/dist/{sso.ee/saml → modules/sso-saml}/errors/invalid-saml-metadata-url.error.js +0 -0
  360. package/dist/{sso.ee/saml → modules/sso-saml}/errors/invalid-saml-metadata.error.d.ts +0 -0
  361. package/dist/{sso.ee/saml → modules/sso-saml}/errors/invalid-saml-metadata.error.js +0 -0
  362. package/dist/{sso.ee/saml → modules/sso-saml}/middleware/saml-enabled-middleware.d.ts +0 -0
  363. package/dist/{sso.ee/saml → modules/sso-saml}/saml-validator.d.ts +0 -0
  364. package/dist/{sso.ee/saml → modules/sso-saml}/saml-validator.js +0 -0
  365. package/dist/{sso.ee/saml → modules/sso-saml}/saml.service.ee.d.ts +2 -2
  366. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/metadata-exchange.xsd.d.ts +0 -0
  367. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/metadata-exchange.xsd.js +0 -0
  368. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.d.ts +0 -0
  369. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.js +0 -0
  370. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.d.ts +0 -0
  371. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.js +0 -0
  372. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-assertion-2.0.xsd.d.ts +0 -0
  373. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-assertion-2.0.xsd.js +0 -0
  374. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-metadata-2.0.xsd.d.ts +0 -0
  375. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-metadata-2.0.xsd.js +0 -0
  376. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-protocol-2.0.xsd.d.ts +0 -0
  377. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/saml-schema-protocol-2.0.xsd.js +0 -0
  378. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-addr.xsd.d.ts +0 -0
  379. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-addr.xsd.js +0 -0
  380. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-authorization.xsd.d.ts +0 -0
  381. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-authorization.xsd.js +0 -0
  382. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-federation.xsd.d.ts +0 -0
  383. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-federation.xsd.js +0 -0
  384. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-securitypolicy-1.2.xsd.d.ts +0 -0
  385. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/ws-securitypolicy-1.2.xsd.js +0 -0
  386. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xenc-schema.xsd.d.ts +0 -0
  387. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xenc-schema.xsd.js +0 -0
  388. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xml.xsd.d.ts +0 -0
  389. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xml.xsd.js +0 -0
  390. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xmldsig-core-schema.xsd.d.ts +0 -0
  391. /package/dist/{sso.ee/saml → modules/sso-saml}/schema/xmldsig-core-schema.xsd.js +0 -0
  392. /package/dist/{sso.ee/saml → modules/sso-saml}/service-provider.ee.d.ts +0 -0
  393. /package/dist/{sso.ee/saml → modules/sso-saml}/service-provider.ee.js +0 -0
  394. /package/dist/{sso.ee/saml → modules/sso-saml}/types.d.ts +0 -0
  395. /package/dist/{sso.ee/saml → modules/sso-saml}/views/init-sso-post.d.ts +0 -0
  396. /package/dist/{sso.ee/saml → modules/sso-saml}/views/init-sso-post.js +0 -0
@@ -17,7 +17,10 @@ const db_1 = require("@n8n/db");
17
17
  const di_1 = require("@n8n/di");
18
18
  const n8n_core_1 = require("n8n-core");
19
19
  const n8n_workflow_1 = require("n8n-workflow");
20
+ const uuid_1 = require("uuid");
20
21
  const active_executions_1 = require("../../active-executions");
22
+ const chat_execution_manager_1 = require("../../chat/chat-execution-manager");
23
+ const execution_not_found_error_1 = require("../../errors/execution-not-found-error");
21
24
  const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
22
25
  const not_found_error_1 = require("../../errors/response-errors/not-found.error");
23
26
  const execution_service_1 = require("../../executions/execution.service");
@@ -34,12 +37,14 @@ const chat_hub_types_1 = require("./chat-hub.types");
34
37
  const chat_message_repository_1 = require("./chat-message.repository");
35
38
  const chat_session_repository_1 = require("./chat-session.repository");
36
39
  const stream_capturer_1 = require("./stream-capturer");
40
+ const utils_1 = require("../../chat/utils");
37
41
  let ChatHubService = class ChatHubService {
38
- constructor(logger, errorReporter, executionService, executionRepository, workflowExecutionService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService, chatHubModelsService, chatHubSettingsService, chatHubAttachmentService, instanceSettings, globalConfig) {
42
+ constructor(logger, errorReporter, executionService, executionRepository, executionManager, workflowExecutionService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService, chatHubModelsService, chatHubSettingsService, chatHubAttachmentService, instanceSettings, globalConfig) {
39
43
  this.logger = logger;
40
44
  this.errorReporter = errorReporter;
41
45
  this.executionService = executionService;
42
46
  this.executionRepository = executionRepository;
47
+ this.executionManager = executionManager;
43
48
  this.workflowExecutionService = workflowExecutionService;
44
49
  this.workflowFinderService = workflowFinderService;
45
50
  this.workflowRepository = workflowRepository;
@@ -92,11 +97,9 @@ let ChatHubService = class ChatHubService {
92
97
  const tz = timeZone ?? this.globalConfig.generic.timezone;
93
98
  const credentialId = this.getModelCredential(model, credentials);
94
99
  let processedAttachments = [];
95
- let executionData;
96
- let workflowData;
97
- let responseMode;
100
+ let workflow;
98
101
  try {
99
- const result = await this.messageRepository.manager.transaction(async (trx) => {
102
+ workflow = await this.messageRepository.manager.transaction(async (trx) => {
100
103
  let session = await this.getChatSession(user, sessionId, trx);
101
104
  session ??= await this.createChatSession(user, sessionId, model, credentialId, tools, payload.agentName, trx);
102
105
  await this.ensurePreviousMessage(previousMessageId, sessionId, trx);
@@ -106,9 +109,6 @@ let ChatHubService = class ChatHubService {
106
109
  await this.saveHumanMessage(payload, processedAttachments, user, previousMessageId, model, undefined, trx);
107
110
  return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, processedAttachments, tz, trx);
108
111
  });
109
- executionData = result.executionData;
110
- workflowData = result.workflowData;
111
- responseMode = result.responseMode;
112
112
  }
113
113
  catch (error) {
114
114
  if (processedAttachments.length > 0) {
@@ -121,17 +121,41 @@ let ChatHubService = class ChatHubService {
121
121
  }
122
122
  throw error;
123
123
  }
124
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model, null, responseMode);
125
- if (previousMessageId === null) {
126
- await this.generateSessionTitle(user, sessionId, message, processedAttachments, credentials, model).catch((error) => {
127
- this.logger.error(`Title generation failed: ${error}`);
124
+ if (!workflow) {
125
+ throw new n8n_workflow_1.UnexpectedError('Failed to prepare chat workflow.');
126
+ }
127
+ const previousMessage = await this.ensurePreviousMessage(previousMessageId, sessionId);
128
+ if (model.provider === 'n8n' &&
129
+ workflow.responseMode === 'responseNodes' &&
130
+ previousMessage?.status === 'waiting' &&
131
+ previousMessage?.executionId) {
132
+ const execution = await this.executionRepository.findSingleExecution(previousMessage.executionId.toString(), {
133
+ includeData: true,
134
+ unflattenData: true,
135
+ });
136
+ if (!execution) {
137
+ throw new n8n_workflow_1.OperationalError('Chat session has expired.');
138
+ }
139
+ this.logger.debug(`Resuming execution ${execution.id} from waiting state for session ${sessionId}`);
140
+ await this.messageRepository.updateChatMessage(previousMessage.id, {
141
+ status: 'success',
128
142
  });
143
+ return await this.resumeChatExecution(execution, message, sessionId, messageId, previousMessage.id, model, res, workflow.responseMode);
144
+ }
145
+ await this.executeChatWorkflowWithCleanup(res, user, model, workflow.workflowData, workflow.executionData, sessionId, messageId, null, workflow.responseMode);
146
+ if (previousMessageId === null) {
147
+ try {
148
+ await this.generateSessionTitle(user, sessionId, message, processedAttachments, credentials, model);
149
+ }
150
+ catch (error) {
151
+ this.logger.warn(`Title generation failed: ${error}`);
152
+ }
129
153
  }
130
154
  }
131
155
  async editMessage(res, user, payload) {
132
156
  const { sessionId, editId, messageId, message, model, credentials, timeZone } = payload;
133
157
  const tz = timeZone ?? this.globalConfig.generic.timezone;
134
- let workflow;
158
+ let workflow = null;
135
159
  let newStoredAttachments = [];
136
160
  try {
137
161
  workflow = await this.messageRepository.manager.transaction(async (trx) => {
@@ -141,6 +165,9 @@ let ChatHubService = class ChatHubService {
141
165
  }
142
166
  const messageToEdit = await this.getChatMessage(session.id, editId, [], trx);
143
167
  if (messageToEdit.type === 'ai') {
168
+ if (model.provider === 'n8n') {
169
+ throw new bad_request_error_1.BadRequestError('Editing AI messages with n8n workflow agents is not supported');
170
+ }
144
171
  await this.messageRepository.updateChatMessage(editId, { content: payload.message }, trx);
145
172
  return null;
146
173
  }
@@ -179,12 +206,12 @@ let ChatHubService = class ChatHubService {
179
206
  return;
180
207
  }
181
208
  const { workflowData, executionData, responseMode } = workflow;
182
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model, null, responseMode);
209
+ await this.executeChatWorkflowWithCleanup(res, user, model, workflowData, executionData, sessionId, messageId, null, responseMode);
183
210
  }
184
211
  async regenerateAIMessage(res, user, payload) {
185
212
  const { sessionId, retryId, model, credentials, timeZone } = payload;
186
213
  const tz = timeZone ?? this.globalConfig.generic.timezone;
187
- const { workflow: { workflowData, executionData, responseMode }, retryOfMessageId, previousMessageId, } = await this.messageRepository.manager.transaction(async (trx) => {
214
+ const { retryOfMessageId, previousMessageId, workflow } = await this.messageRepository.manager.transaction(async (trx) => {
188
215
  const session = await this.getChatSession(user, sessionId, trx);
189
216
  if (!session) {
190
217
  throw new not_found_error_1.NotFoundError('Chat session not found');
@@ -208,16 +235,16 @@ let ChatHubService = class ChatHubService {
208
235
  const attachments = lastHumanMessage.attachments ?? [];
209
236
  const workflow = await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, tz, trx);
210
237
  return {
211
- workflow,
212
238
  previousMessageId: lastHumanMessage.id,
213
239
  retryOfMessageId,
240
+ workflow,
214
241
  };
215
242
  });
216
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, responseMode);
243
+ await this.executeChatWorkflowWithCleanup(res, user, model, workflow.workflowData, workflow.executionData, sessionId, previousMessageId, retryOfMessageId, workflow.responseMode);
217
244
  }
218
245
  async prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, attachments, timeZone, trx) {
219
246
  if (model.provider === 'n8n') {
220
- return await this.prepareCustomAgentWorkflow(user, sessionId, model.workflowId, message, attachments);
247
+ return await this.prepareWorkflowAgentWorkflow(user, sessionId, model.workflowId, message, attachments, trx);
221
248
  }
222
249
  if (model.provider === 'custom-agent') {
223
250
  return await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, attachments, timeZone, trx);
@@ -231,7 +258,7 @@ let ChatHubService = class ChatHubService {
231
258
  return await this.chatHubWorkflowService.createChatWorkflow(user.id, sessionId, projectId, history, message, attachments, credentials, model, systemMessage, tools, timeZone, trx);
232
259
  }
233
260
  async prepareChatAgentWorkflow(agentId, user, sessionId, history, message, attachments, timeZone, trx) {
234
- const agent = await this.chatHubAgentService.getAgentById(agentId, user.id);
261
+ const agent = await this.chatHubAgentService.getAgentById(agentId, user.id, trx);
235
262
  if (!agent) {
236
263
  throw new bad_request_error_1.BadRequestError('Agent not found');
237
264
  }
@@ -256,8 +283,8 @@ let ChatHubService = class ChatHubService {
256
283
  const { tools } = agent;
257
284
  return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, timeZone, trx);
258
285
  }
259
- async prepareCustomAgentWorkflow(user, sessionId, workflowId, message, attachments) {
260
- const workflow = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true });
286
+ async prepareWorkflowAgentWorkflow(user, sessionId, workflowId, message, attachments, trx) {
287
+ const workflow = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true, em: trx });
261
288
  if (!workflow?.activeVersion) {
262
289
  throw new bad_request_error_1.BadRequestError('Workflow not found');
263
290
  }
@@ -277,12 +304,12 @@ let ChatHubService = class ChatHubService {
277
304
  throw new bad_request_error_1.BadRequestError('Chat Trigger node must be made available in Chat');
278
305
  }
279
306
  const responseMode = chatTriggerParams.options?.responseMode ?? 'streaming';
280
- if (responseMode !== 'streaming') {
281
- throw new bad_request_error_1.BadRequestError('Chat Trigger node response mode must be set to streaming to use the workflow on Chat');
307
+ if (!chat_hub_constants_1.SUPPORTED_RESPONSE_MODES.includes(responseMode)) {
308
+ throw new bad_request_error_1.BadRequestError('Chat Trigger node response mode must be set to "When Last Node Finishes", "Using Response Nodes" or "Streaming" to use the workflow on Chat');
282
309
  }
283
- const chatResponseNodes = workflow.activeVersion.nodes.filter((node) => node.type === n8n_workflow_1.RESPOND_TO_CHAT_NODE_TYPE);
284
- if (chatResponseNodes.length > 0) {
285
- throw new bad_request_error_1.BadRequestError('Respond to Chat nodes are not supported in custom agent workflows');
310
+ const chatResponseNodes = workflow.activeVersion.nodes.filter((node) => node.type === n8n_workflow_1.CHAT_NODE_TYPE);
311
+ if (chatResponseNodes.length > 0 && responseMode !== 'responseNodes') {
312
+ throw new bad_request_error_1.BadRequestError('Chat nodes are not supported with the selected response mode. Please set the response mode to "Using Response Nodes" or remove the nodes from the workflow.');
286
313
  }
287
314
  const agentNodes = workflow.activeVersion.nodes?.filter((node) => node.type === n8n_workflow_1.AGENT_LANGCHAIN_NODE_TYPE);
288
315
  if (agentNodes.some((node) => node.typeVersion < chat_hub_constants_1.TOOLS_AGENT_NODE_MIN_VERSION)) {
@@ -301,6 +328,10 @@ let ChatHubService = class ChatHubService {
301
328
  ...workflow,
302
329
  nodes: workflow.activeVersion.nodes,
303
330
  connections: workflow.activeVersion.connections,
331
+ settings: {
332
+ ...workflow.settings,
333
+ saveDataSuccessExecution: 'all',
334
+ },
304
335
  };
305
336
  return {
306
337
  workflowData,
@@ -316,6 +347,7 @@ let ChatHubService = class ChatHubService {
316
347
  if (!previousMessage) {
317
348
  throw new bad_request_error_1.BadRequestError('The previous message does not exist in the session');
318
349
  }
350
+ return previousMessage;
319
351
  }
320
352
  async stopGeneration(user, sessionId, messageId) {
321
353
  await this.ensureConversation(user.id, sessionId);
@@ -335,11 +367,210 @@ let ChatHubService = class ChatHubService {
335
367
  await this.executionService.stop(message.execution.id, [message.execution.workflowId]);
336
368
  await this.messageRepository.updateChatMessage(messageId, { status: 'cancelled' });
337
369
  }
338
- async executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId = null, executionMode = 'chat', responseMode) {
370
+ async executeChatWorkflow(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId = null, executionMode = 'chat', responseMode) {
339
371
  this.logger.debug(`Starting execution of workflow "${workflowData.name}" with ID ${workflowData.id}`);
340
- if (responseMode !== 'streaming') {
372
+ if (!chat_hub_constants_1.SUPPORTED_RESPONSE_MODES.includes(responseMode)) {
341
373
  throw new bad_request_error_1.BadRequestError(`Response mode "${responseMode}" is not supported yet.`);
342
374
  }
375
+ if (responseMode === 'lastNode' || responseMode === 'responseNodes') {
376
+ return await this.executeLastNode(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, executionMode, responseMode);
377
+ }
378
+ else if (responseMode === 'streaming') {
379
+ return await this.executeWithStreaming(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, executionMode);
380
+ }
381
+ }
382
+ async executeLastNode(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, executionMode, responseMode) {
383
+ const running = await this.workflowExecutionService.executeChatWorkflow(user, workflowData, executionData, undefined, false, executionMode);
384
+ const messageId = (0, uuid_1.v4)();
385
+ const executionId = running.executionId;
386
+ if (!executionId) {
387
+ throw new n8n_workflow_1.OperationalError('There was a problem starting the chat execution.');
388
+ }
389
+ await this.beginResponse(res, executionId, messageId, sessionId, model, previousMessageId, retryOfMessageId);
390
+ try {
391
+ await this.waitForExecutionCompletion(executionId);
392
+ const execution = await this.executionRepository.findSingleExecution(executionId, {
393
+ includeData: true,
394
+ unflattenData: true,
395
+ });
396
+ if (!execution) {
397
+ throw new n8n_workflow_1.OperationalError('Chat execution not found after completion - make sure your instance is saving executions.');
398
+ }
399
+ if (!['success', 'waiting', 'canceled'].includes(execution.status)) {
400
+ const errorMessage = this.getErrorMessage(execution) ?? 'Failed to generate a response';
401
+ throw new n8n_workflow_1.OperationalError(errorMessage);
402
+ }
403
+ const message = this.getMessage(execution, responseMode);
404
+ const status = execution?.status === 'waiting' ? 'waiting' : 'success';
405
+ await this.endResponse(res, message ?? '', status, executionId, messageId, previousMessageId, retryOfMessageId);
406
+ if (status === 'waiting' && responseMode === 'responseNodes') {
407
+ const lastNode = (0, utils_1.getLastNodeExecuted)(execution);
408
+ if (lastNode && (0, utils_1.shouldResumeImmediately)(lastNode)) {
409
+ this.logger.debug(`Resuming execution ${execution.id} immediately after wait in node ${lastNode.name}`);
410
+ await this.resumeChatExecution(execution, '', sessionId, messageId, messageId, model, res, responseMode);
411
+ }
412
+ }
413
+ }
414
+ catch (e) {
415
+ if (e instanceof n8n_workflow_1.ManualExecutionCancelledError) {
416
+ return;
417
+ }
418
+ const message = e instanceof Error ? e.message : 'Unknown error occurred during chat execution';
419
+ await this.endResponse(res, message ?? '', 'error', executionId, messageId, previousMessageId, retryOfMessageId);
420
+ }
421
+ }
422
+ async resumeChatExecution(execution, message, sessionId, messageId, previousMessageId, model, res, responseMode) {
423
+ await this.messageRepository.updateChatMessage(previousMessageId, {
424
+ status: 'success',
425
+ });
426
+ while (true) {
427
+ await this.resumeExecution(sessionId, execution, message);
428
+ previousMessageId = messageId;
429
+ messageId = (0, uuid_1.v4)();
430
+ await this.beginResponse(res, execution.id, messageId, sessionId, model, previousMessageId, null);
431
+ await this.waitForExecutionCompletion(execution.id);
432
+ const completed = await this.executionRepository.findSingleExecution(execution.id, {
433
+ includeData: true,
434
+ unflattenData: true,
435
+ });
436
+ if (!completed) {
437
+ throw new n8n_workflow_1.OperationalError('Chat execution not found after completion - make sure your instance is saving executions.');
438
+ }
439
+ if (!['success', 'waiting', 'canceled'].includes(completed.status)) {
440
+ const message = this.getErrorMessage(completed) ?? 'Failed to generate a response';
441
+ throw new n8n_workflow_1.OperationalError(message);
442
+ }
443
+ const reply = this.getMessage(completed, responseMode);
444
+ const status = completed?.status === 'waiting' ? 'waiting' : 'success';
445
+ await this.endResponse(res, reply ?? '', status, execution.id, messageId, previousMessageId, null);
446
+ const lastNode = (0, utils_1.getLastNodeExecuted)(completed);
447
+ if (status === 'waiting' && lastNode && (0, utils_1.shouldResumeImmediately)(lastNode)) {
448
+ this.logger.debug(`Resuming execution ${completed.id} immediately after wait in node ${lastNode.name}`);
449
+ await this.messageRepository.updateChatMessage(messageId, {
450
+ status: 'success',
451
+ });
452
+ message = '';
453
+ execution = completed;
454
+ }
455
+ else {
456
+ return;
457
+ }
458
+ }
459
+ }
460
+ getMessage(execution, responseMode) {
461
+ const nodeName = this.getLastNodeExecuted(execution);
462
+ if (!nodeName)
463
+ return undefined;
464
+ const outputs = this.getNodeOutputs(execution, nodeName);
465
+ const entry = this.getFirstOutputEntry(outputs);
466
+ if (!entry)
467
+ return undefined;
468
+ const message = this.extractMessage(entry, responseMode);
469
+ if (typeof message === 'object' && message !== null) {
470
+ return (0, n8n_workflow_1.jsonStringify)(message);
471
+ }
472
+ return message;
473
+ }
474
+ getLastNodeExecuted(execution) {
475
+ const lastNodeExecuted = execution.data.resultData.lastNodeExecuted;
476
+ return typeof lastNodeExecuted === 'string' ? lastNodeExecuted : undefined;
477
+ }
478
+ getNodeOutputs(execution, nodeName) {
479
+ const runData = execution.data.resultData.runData[nodeName];
480
+ if (!runData || runData.length === 0)
481
+ return [];
482
+ const runIndex = runData.length - 1;
483
+ const data = runData[runIndex]?.data;
484
+ return data?.main ?? data?.[n8n_workflow_1.NodeConnectionTypes.AiTool] ?? [];
485
+ }
486
+ getFirstOutputEntry(outputs) {
487
+ for (const branch of outputs) {
488
+ if (!Array.isArray(branch) || branch.length === 0)
489
+ continue;
490
+ return branch[0];
491
+ }
492
+ return undefined;
493
+ }
494
+ extractMessage(entry, responseMode) {
495
+ if (responseMode === 'responseNodes') {
496
+ return entry.sendMessage ?? '';
497
+ }
498
+ if (responseMode === 'lastNode') {
499
+ const response = entry.json ?? {};
500
+ const message = response.output ?? response.text ?? response.message ?? '';
501
+ return typeof message === 'string' ? message : (0, n8n_workflow_1.jsonStringify)(message);
502
+ }
503
+ return undefined;
504
+ }
505
+ async beginResponse(res, executionId, messageId, sessionId, model, previousMessageId, retryOfMessageId) {
506
+ const beginChunk = {
507
+ type: 'begin',
508
+ metadata: {
509
+ timestamp: Date.now(),
510
+ messageId,
511
+ previousMessageId,
512
+ retryOfMessageId,
513
+ executionId: executionId ? parseInt(executionId, 10) : null,
514
+ },
515
+ };
516
+ if (!res.headersSent) {
517
+ res.writeHead(200, chat_hub_constants_1.JSONL_STREAM_HEADERS);
518
+ res.flushHeaders();
519
+ }
520
+ res.write((0, n8n_workflow_1.jsonStringify)(beginChunk) + '\n');
521
+ res.flush();
522
+ await this.saveAIMessage({
523
+ id: messageId,
524
+ content: '',
525
+ sessionId,
526
+ executionId: executionId ?? undefined,
527
+ model,
528
+ previousMessageId,
529
+ retryOfMessageId,
530
+ status: 'running',
531
+ });
532
+ }
533
+ async endResponse(res, content, status, executionId, messageId, previousMessageId, retryOfMessageId) {
534
+ const contentChunk = {
535
+ type: status === 'error' ? 'error' : 'item',
536
+ content,
537
+ metadata: {
538
+ timestamp: Date.now(),
539
+ messageId,
540
+ previousMessageId,
541
+ retryOfMessageId,
542
+ executionId: executionId ? parseInt(executionId, 10) : null,
543
+ },
544
+ };
545
+ res.write((0, n8n_workflow_1.jsonStringify)(contentChunk) + '\n');
546
+ res.flush();
547
+ if (status !== 'error') {
548
+ const endChunk = {
549
+ type: 'end',
550
+ metadata: {
551
+ timestamp: Date.now(),
552
+ messageId,
553
+ previousMessageId,
554
+ retryOfMessageId,
555
+ executionId: executionId ? parseInt(executionId, 10) : null,
556
+ },
557
+ };
558
+ res.write((0, n8n_workflow_1.jsonStringify)(endChunk) + '\n');
559
+ res.flush();
560
+ }
561
+ await this.messageRepository.updateChatMessage(messageId, {
562
+ content,
563
+ status,
564
+ });
565
+ }
566
+ async resumeExecution(sessionId, execution, message) {
567
+ await this.executionManager.runWorkflow(execution, {
568
+ action: 'sendMessage',
569
+ chatInput: message,
570
+ sessionId,
571
+ });
572
+ }
573
+ async executeWithStreaming(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, executionMode) {
343
574
  let executionId = undefined;
344
575
  const aggregator = (0, stream_capturer_1.createStructuredChunkAggregator)(previousMessageId, retryOfMessageId, {
345
576
  onBegin: async (message) => {
@@ -391,17 +622,17 @@ let ChatHubService = class ChatHubService {
391
622
  : 'Request was not processed';
392
623
  }
393
624
  const message = await aggregator.ingest(chunk);
394
- const enriched = {
625
+ const messageChunk = {
395
626
  ...chunk,
396
627
  metadata: {
397
- ...chunk.metadata,
628
+ timestamp: chunk.metadata.timestamp,
398
629
  messageId: message.id,
399
630
  previousMessageId: message.previousMessageId,
400
631
  retryOfMessageId: message.retryOfMessageId,
401
632
  executionId: executionId ? +executionId : null,
402
633
  },
403
634
  };
404
- return (0, n8n_workflow_1.jsonStringify)(enriched) + '\n';
635
+ return (0, n8n_workflow_1.jsonStringify)(messageChunk) + '\n';
405
636
  };
406
637
  const stream = (0, stream_capturer_1.interceptResponseWrites)(res, transform);
407
638
  let onStreamClosed = () => { };
@@ -413,7 +644,7 @@ let ChatHubService = class ChatHubService {
413
644
  stream.on('close', onStreamClosed);
414
645
  stream.writeHead(200, chat_hub_constants_1.JSONL_STREAM_HEADERS);
415
646
  stream.flushHeaders();
416
- const execution = await this.workflowExecutionService.executeChatWorkflow(workflowData, executionData, user, stream, true, executionMode);
647
+ const execution = await this.workflowExecutionService.executeChatWorkflow(user, workflowData, executionData, stream, true, executionMode);
417
648
  executionId = execution.executionId;
418
649
  if (!executionId) {
419
650
  throw new n8n_workflow_1.OperationalError('There was a problem starting the chat execution.');
@@ -446,14 +677,19 @@ let ChatHubService = class ChatHubService {
446
677
  return await new Promise((resolve, reject) => {
447
678
  const poller = setInterval(async () => {
448
679
  try {
449
- const result = await this.executionRepository.findSingleExecution(executionId, {
680
+ const execution = await this.executionRepository.findSingleExecution(executionId, {
450
681
  includeData: false,
451
682
  unflattenData: false,
452
683
  });
453
- if (!result || chat_hub_constants_1.EXECUTION_FINISHED_STATUSES.includes(result.status)) {
454
- this.logger.debug(`Execution ${executionId} finished with status ${result?.status ?? 'missing'}`);
684
+ if (!execution || chat_hub_constants_1.EXECUTION_FINISHED_STATUSES.includes(execution.status)) {
685
+ this.logger.debug(`Execution ${executionId} finished with status ${execution?.status ?? 'missing'}`);
455
686
  clearInterval(poller);
456
- resolve();
687
+ if (execution?.status === 'canceled') {
688
+ reject(new n8n_workflow_1.ManualExecutionCancelledError(executionId));
689
+ }
690
+ else {
691
+ resolve();
692
+ }
457
693
  }
458
694
  }
459
695
  catch (error) {
@@ -485,19 +721,22 @@ let ChatHubService = class ChatHubService {
485
721
  }
486
722
  }
487
723
  catch (error) {
488
- if (error instanceof n8n_workflow_1.ManualExecutionCancelledError) {
724
+ if (error instanceof execution_not_found_error_1.ExecutionNotFoundError) {
489
725
  return;
490
726
  }
727
+ if (error instanceof n8n_workflow_1.ManualExecutionCancelledError) {
728
+ throw error;
729
+ }
491
730
  if (error instanceof Error) {
492
731
  this.logger.error(`Error during chat workflow execution: ${error}`);
493
732
  }
494
733
  throw error;
495
734
  }
496
735
  }
497
- async executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, responseMode) {
736
+ async executeChatWorkflowWithCleanup(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, responseMode) {
498
737
  try {
499
738
  const executionMode = model.provider === 'n8n' ? 'webhook' : 'chat';
500
- await this.executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, executionMode, responseMode);
739
+ await this.executeChatWorkflow(res, user, model, workflowData, executionData, sessionId, previousMessageId, retryOfMessageId, executionMode, responseMode);
501
740
  }
502
741
  finally {
503
742
  if (model.provider !== 'n8n') {
@@ -513,12 +752,6 @@ let ChatHubService = class ChatHubService {
513
752
  await this.sessionRepository.updateChatSession(sessionId, { title });
514
753
  }
515
754
  }
516
- catch (error) {
517
- if (error instanceof Error) {
518
- this.logger.error(`Error during session title generation workflow execution: ${error}`);
519
- }
520
- throw error;
521
- }
522
755
  finally {
523
756
  await this.deleteChatWorkflow(workflowData.id);
524
757
  }
@@ -552,24 +785,24 @@ let ChatHubService = class ChatHubService {
552
785
  async resolveFromN8nWorkflow(user, { workflowId }, trx) {
553
786
  const workflowEntity = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true, em: trx });
554
787
  if (!workflowEntity?.activeVersion) {
555
- throw new bad_request_error_1.BadRequestError('Workflow not found for title generation');
788
+ throw new n8n_workflow_1.UserError('Workflow not found for title generation');
556
789
  }
557
790
  const modelNodes = this.findSupportedLLMNodes(workflowEntity.activeVersion.nodes);
558
791
  this.logger.debug(`Found ${modelNodes.length} LLM nodes in workflow ${workflowEntity.id} for title generation`);
559
792
  if (modelNodes.length === 0) {
560
- throw new bad_request_error_1.BadRequestError('No supported Model nodes found in workflow for title generation');
793
+ throw new n8n_workflow_1.UserError('No supported Model nodes found in workflow for title generation');
561
794
  }
562
795
  const modelNode = modelNodes[0];
563
796
  const llmModel = modelNode.node.parameters?.model?.value;
564
797
  if (!llmModel) {
565
- throw new bad_request_error_1.BadRequestError(`No model set on Model node "${modelNode.node.name}" for title generation`);
798
+ throw new n8n_workflow_1.UserError(`No model set on Model node "${modelNode.node.name}" for title generation`);
566
799
  }
567
800
  if (typeof llmModel !== 'string' || llmModel.length === 0 || llmModel.startsWith('=')) {
568
- throw new bad_request_error_1.BadRequestError(`Invalid model set on Model node "${modelNode.node.name}" for title generation`);
801
+ throw new n8n_workflow_1.UserError(`Invalid model set on Model node "${modelNode.node.name}" for title generation`);
569
802
  }
570
803
  const llmCredentials = modelNode.node.credentials;
571
804
  if (!llmCredentials) {
572
- throw new bad_request_error_1.BadRequestError(`No credentials found on Model node "${modelNode.node.name}" for title generation`);
805
+ throw new n8n_workflow_1.UserError(`No credentials found on Model node "${modelNode.node.name}" for title generation`);
573
806
  }
574
807
  const { credentialId, projectId } = await this.chatHubCredentialsService.findWorkflowCredentialAndProject(modelNode.provider, llmCredentials, workflowId);
575
808
  const resolvedModel = {
@@ -595,7 +828,7 @@ let ChatHubService = class ChatHubService {
595
828
  }, []);
596
829
  }
597
830
  async resolveFromCustomAgent(user, model, trx) {
598
- const agent = await this.chatHubAgentService.getAgentById(model.agentId, user.id);
831
+ const agent = await this.chatHubAgentService.getAgentById(model.agentId, user.id, trx);
599
832
  if (!agent) {
600
833
  throw new bad_request_error_1.BadRequestError('Agent not found for title generation');
601
834
  }
@@ -617,7 +850,7 @@ let ChatHubService = class ChatHubService {
617
850
  return { resolvedCredentials, resolvedModel, credentialId, projectId };
618
851
  }
619
852
  async runTitleWorkflowAndGetTitle(user, workflowData, executionData) {
620
- const { executionId } = await this.workflowExecutionService.executeChatWorkflow(workflowData, executionData, user, undefined, false, 'chat');
853
+ const { executionId } = await this.workflowExecutionService.executeChatWorkflow(user, workflowData, executionData, undefined, false, 'chat');
621
854
  await this.waitForExecutionCompletion(executionId);
622
855
  const execution = await this.executionRepository.findWithUnflattenedData(executionId, [
623
856
  workflowData.id,
@@ -668,7 +901,7 @@ let ChatHubService = class ChatHubService {
668
901
  return await this.sessionRepository.getOneById(sessionId, user.id, trx);
669
902
  }
670
903
  async createChatSession(user, sessionId, model, credentialId, tools, agentName, trx) {
671
- await this.ensureValidModel(user, model);
904
+ await this.ensureValidModel(user, model, trx);
672
905
  return await this.sessionRepository.createChatSession({
673
906
  id: sessionId,
674
907
  ownerId: user.id,
@@ -797,15 +1030,15 @@ let ChatHubService = class ChatHubService {
797
1030
  await this.sessionRepository.deleteChatHubSession(sessionId, trx);
798
1031
  });
799
1032
  }
800
- async ensureValidModel(user, model) {
1033
+ async ensureValidModel(user, model, trx) {
801
1034
  if (model.provider === 'custom-agent') {
802
- const agent = await this.chatHubAgentService.getAgentById(model.agentId, user.id);
1035
+ const agent = await this.chatHubAgentService.getAgentById(model.agentId, user.id, trx);
803
1036
  if (!agent) {
804
1037
  throw new bad_request_error_1.BadRequestError('Agent not found for chat session initialization');
805
1038
  }
806
1039
  }
807
1040
  if (model.provider === 'n8n') {
808
- const workflowEntity = await this.workflowFinderService.findWorkflowForUser(model.workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true });
1041
+ const workflowEntity = await this.workflowFinderService.findWorkflowForUser(model.workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true, em: trx });
809
1042
  if (!workflowEntity?.activeVersion) {
810
1043
  throw new bad_request_error_1.BadRequestError('Workflow not found for chat session initialization');
811
1044
  }
@@ -871,6 +1104,7 @@ exports.ChatHubService = ChatHubService = __decorate([
871
1104
  n8n_core_1.ErrorReporter,
872
1105
  execution_service_1.ExecutionService,
873
1106
  db_1.ExecutionRepository,
1107
+ chat_execution_manager_1.ChatExecutionManager,
874
1108
  workflow_execution_service_1.WorkflowExecutionService,
875
1109
  workflow_finder_service_1.WorkflowFinderService,
876
1110
  db_1.WorkflowRepository,