n8n 2.0.3 → 2.1.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 (349) hide show
  1. package/dist/active-executions.js +7 -1
  2. package/dist/active-executions.js.map +1 -1
  3. package/dist/active-workflow-manager.d.ts +0 -1
  4. package/dist/active-workflow-manager.js +5 -8
  5. package/dist/active-workflow-manager.js.map +1 -1
  6. package/dist/auth/auth.service.js +1 -7
  7. package/dist/auth/auth.service.js.map +1 -1
  8. package/dist/build.tsbuildinfo +1 -1
  9. package/dist/commands/base-command.js +1 -2
  10. package/dist/commands/base-command.js.map +1 -1
  11. package/dist/commands/start.js +3 -0
  12. package/dist/commands/start.js.map +1 -1
  13. package/dist/commands/user-management/reset.js +1 -1
  14. package/dist/commands/user-management/reset.js.map +1 -1
  15. package/dist/commands/worker.js +3 -0
  16. package/dist/commands/worker.js.map +1 -1
  17. package/dist/concurrency/concurrency-control.service.js +2 -1
  18. package/dist/concurrency/concurrency-control.service.js.map +1 -1
  19. package/dist/config/schema.js.map +1 -1
  20. package/dist/config/types.d.ts +0 -1
  21. package/dist/controllers/ai.controller.d.ts +3 -0
  22. package/dist/controllers/ai.controller.js +2 -1
  23. package/dist/controllers/ai.controller.js.map +1 -1
  24. package/dist/controllers/api-keys.controller.js +5 -0
  25. package/dist/controllers/api-keys.controller.js.map +1 -1
  26. package/dist/controllers/e2e.controller.d.ts +1 -0
  27. package/dist/controllers/e2e.controller.js +10 -11
  28. package/dist/controllers/e2e.controller.js.map +1 -1
  29. package/dist/controllers/invitation.controller.d.ts +3 -1
  30. package/dist/controllers/invitation.controller.js +6 -7
  31. package/dist/controllers/invitation.controller.js.map +1 -1
  32. package/dist/controllers/oauth/oauth1-credential.controller.d.ts +6 -3
  33. package/dist/controllers/oauth/oauth1-credential.controller.js +39 -57
  34. package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
  35. package/dist/controllers/oauth/oauth2-credential.controller.d.ts +8 -5
  36. package/dist/controllers/oauth/oauth2-credential.controller.js +41 -179
  37. package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
  38. package/dist/controllers/owner.controller.d.ts +4 -10
  39. package/dist/controllers/owner.controller.js +6 -42
  40. package/dist/controllers/owner.controller.js.map +1 -1
  41. package/dist/controllers/project.controller.d.ts +4 -0
  42. package/dist/credentials/credential-resolution-provider.interface.d.ts +12 -0
  43. package/dist/credentials/credential-resolution-provider.interface.js +3 -0
  44. package/dist/credentials/credential-resolution-provider.interface.js.map +1 -0
  45. package/dist/credentials/credentials-finder.service.d.ts +4 -0
  46. package/dist/credentials/credentials-finder.service.js +3 -0
  47. package/dist/credentials/credentials-finder.service.js.map +1 -1
  48. package/dist/credentials/credentials.controller.d.ts +12 -4
  49. package/dist/credentials/credentials.controller.js +9 -6
  50. package/dist/credentials/credentials.controller.js.map +1 -1
  51. package/dist/credentials/credentials.service.d.ts +13 -0
  52. package/dist/credentials/credentials.service.ee.d.ts +9 -2
  53. package/dist/credentials/credentials.service.ee.js +4 -1
  54. package/dist/credentials/credentials.service.ee.js.map +1 -1
  55. package/dist/credentials/credentials.service.js +10 -6
  56. package/dist/credentials/credentials.service.js.map +1 -1
  57. package/dist/credentials/dynamic-credential-storage.interface.d.ts +11 -0
  58. package/dist/credentials/dynamic-credential-storage.interface.js +3 -0
  59. package/dist/credentials/dynamic-credential-storage.interface.js.map +1 -0
  60. package/dist/credentials/dynamic-credentials-proxy.d.ts +14 -0
  61. package/dist/credentials/dynamic-credentials-proxy.js +50 -0
  62. package/dist/credentials/dynamic-credentials-proxy.js.map +1 -0
  63. package/dist/credentials-helper.d.ts +5 -2
  64. package/dist/credentials-helper.js +25 -7
  65. package/dist/credentials-helper.js.map +1 -1
  66. package/dist/environments.ee/source-control/source-control-import.service.ee.js.map +1 -1
  67. package/dist/environments.ee/source-control/source-control-status.service.ee.d.ts +2 -2
  68. package/dist/environments.ee/source-control/source-control.controller.ee.d.ts +4 -4
  69. package/dist/environments.ee/source-control/source-control.service.ee.d.ts +2 -2
  70. package/dist/environments.ee/source-control/source-control.service.ee.js +67 -39
  71. package/dist/environments.ee/source-control/source-control.service.ee.js.map +1 -1
  72. package/dist/errors/single-webhook-trigger.error.d.ts +4 -0
  73. package/dist/errors/single-webhook-trigger.error.js +11 -0
  74. package/dist/errors/single-webhook-trigger.error.js.map +1 -0
  75. package/dist/eventbus/event-message-classes/index.d.ts +2 -2
  76. package/dist/eventbus/event-message-classes/index.js +1 -0
  77. package/dist/eventbus/event-message-classes/index.js.map +1 -1
  78. package/dist/events/maps/relay.event-map.d.ts +6 -1
  79. package/dist/events/relays/log-streaming.event-relay.d.ts +1 -0
  80. package/dist/events/relays/log-streaming.event-relay.js +12 -0
  81. package/dist/events/relays/log-streaming.event-relay.js.map +1 -1
  82. package/dist/events/relays/telemetry.event-relay.js +14 -3
  83. package/dist/events/relays/telemetry.event-relay.js.map +1 -1
  84. package/dist/execution-lifecycle/execution-lifecycle-hooks.d.ts +2 -2
  85. package/dist/execution-lifecycle/execution-lifecycle-hooks.js +15 -3
  86. package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
  87. package/dist/license.d.ts +6 -0
  88. package/dist/license.js +27 -0
  89. package/dist/license.js.map +1 -1
  90. package/dist/load-nodes-and-credentials.d.ts +2 -0
  91. package/dist/load-nodes-and-credentials.js +97 -86
  92. package/dist/load-nodes-and-credentials.js.map +1 -1
  93. package/dist/modules/breaking-changes/rules/index.d.ts +1 -1
  94. package/dist/modules/breaking-changes/rules/v2/index.d.ts +2 -1
  95. package/dist/modules/breaking-changes/rules/v2/index.js +2 -0
  96. package/dist/modules/breaking-changes/rules/v2/index.js.map +1 -1
  97. package/dist/modules/breaking-changes/rules/v2/pyodide-removed.rule.js +2 -1
  98. package/dist/modules/breaking-changes/rules/v2/pyodide-removed.rule.js.map +1 -1
  99. package/dist/modules/breaking-changes/rules/v2/settings-file-permissions.rule.d.ts +3 -3
  100. package/dist/modules/breaking-changes/rules/v2/settings-file-permissions.rule.js +11 -4
  101. package/dist/modules/breaking-changes/rules/v2/settings-file-permissions.rule.js.map +1 -1
  102. package/dist/modules/breaking-changes/rules/v2/start-node-removed.rule.d.ts +11 -0
  103. package/dist/modules/breaking-changes/rules/v2/start-node-removed.rule.js +63 -0
  104. package/dist/modules/breaking-changes/rules/v2/start-node-removed.rule.js.map +1 -0
  105. package/dist/modules/breaking-changes/rules/v2/task-runner-docker-image.rule.d.ts +3 -0
  106. package/dist/modules/breaking-changes/rules/v2/task-runner-docker-image.rule.js +15 -2
  107. package/dist/modules/breaking-changes/rules/v2/task-runner-docker-image.rule.js.map +1 -1
  108. package/dist/modules/breaking-changes/rules/v2/task-runners.rule.d.ts +3 -2
  109. package/dist/modules/breaking-changes/rules/v2/task-runners.rule.js +11 -2
  110. package/dist/modules/breaking-changes/rules/v2/task-runners.rule.js.map +1 -1
  111. package/dist/modules/chat-hub/chat-hub-agent.entity.d.ts +4 -3
  112. package/dist/modules/chat-hub/chat-hub-agent.entity.js +4 -0
  113. package/dist/modules/chat-hub/chat-hub-agent.entity.js.map +1 -1
  114. package/dist/modules/chat-hub/chat-hub-agent.service.d.ts +5 -21
  115. package/dist/modules/chat-hub/chat-hub-agent.service.js +17 -11
  116. package/dist/modules/chat-hub/chat-hub-agent.service.js.map +1 -1
  117. package/dist/modules/chat-hub/chat-hub-credentials.service.js +4 -2
  118. package/dist/modules/chat-hub/chat-hub-credentials.service.js.map +1 -1
  119. package/dist/modules/chat-hub/chat-hub-message.entity.js +1 -1
  120. package/dist/modules/chat-hub/chat-hub-message.entity.js.map +1 -1
  121. package/dist/modules/chat-hub/chat-hub-session.entity.d.ts +2 -0
  122. package/dist/modules/chat-hub/chat-hub-session.entity.js +6 -1
  123. package/dist/modules/chat-hub/chat-hub-session.entity.js.map +1 -1
  124. package/dist/modules/chat-hub/chat-hub-workflow.service.d.ts +17 -4
  125. package/dist/modules/chat-hub/chat-hub-workflow.service.js +161 -31
  126. package/dist/modules/chat-hub/chat-hub-workflow.service.js.map +1 -1
  127. package/dist/modules/chat-hub/chat-hub.attachment.service.d.ts +2 -0
  128. package/dist/modules/chat-hub/chat-hub.attachment.service.js +12 -0
  129. package/dist/modules/chat-hub/chat-hub.attachment.service.js.map +1 -1
  130. package/dist/modules/chat-hub/chat-hub.constants.d.ts +7 -3
  131. package/dist/modules/chat-hub/chat-hub.constants.js +468 -10
  132. package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
  133. package/dist/modules/chat-hub/chat-hub.controller.d.ts +3 -1
  134. package/dist/modules/chat-hub/chat-hub.controller.js +7 -14
  135. package/dist/modules/chat-hub/chat-hub.controller.js.map +1 -1
  136. package/dist/modules/chat-hub/chat-hub.models.service.d.ts +35 -0
  137. package/dist/modules/chat-hub/chat-hub.models.service.js +640 -0
  138. package/dist/modules/chat-hub/chat-hub.models.service.js.map +1 -0
  139. package/dist/modules/chat-hub/chat-hub.module.js +0 -8
  140. package/dist/modules/chat-hub/chat-hub.module.js.map +1 -1
  141. package/dist/modules/chat-hub/chat-hub.service.d.ts +13 -26
  142. package/dist/modules/chat-hub/chat-hub.service.js +162 -760
  143. package/dist/modules/chat-hub/chat-hub.service.js.map +1 -1
  144. package/dist/modules/chat-hub/chat-hub.types.d.ts +27 -6
  145. package/dist/modules/chat-hub/chat-hub.types.js +11 -3
  146. package/dist/modules/chat-hub/chat-hub.types.js.map +1 -1
  147. package/dist/modules/chat-hub/chat-session.repository.js +17 -2
  148. package/dist/modules/chat-hub/chat-session.repository.js.map +1 -1
  149. package/dist/modules/chat-hub/context-limits.js +62 -5
  150. package/dist/modules/chat-hub/context-limits.js.map +1 -1
  151. package/dist/modules/data-table/data-table-column.repository.d.ts +15 -0
  152. package/dist/modules/data-table/data-table-column.repository.js +33 -17
  153. package/dist/modules/data-table/data-table-column.repository.js.map +1 -1
  154. package/dist/modules/data-table/data-table-ddl.service.d.ts +1 -0
  155. package/dist/modules/data-table/data-table-ddl.service.js +5 -0
  156. package/dist/modules/data-table/data-table-ddl.service.js.map +1 -1
  157. package/dist/modules/data-table/data-table-rows.repository.js +1 -1
  158. package/dist/modules/data-table/data-table-rows.repository.js.map +1 -1
  159. package/dist/modules/data-table/data-table.controller.d.ts +16 -1
  160. package/dist/modules/data-table/data-table.controller.js +39 -35
  161. package/dist/modules/data-table/data-table.controller.js.map +1 -1
  162. package/dist/modules/data-table/data-table.repository.d.ts +4 -1
  163. package/dist/modules/data-table/data-table.repository.js +12 -2
  164. package/dist/modules/data-table/data-table.repository.js.map +1 -1
  165. package/dist/modules/data-table/data-table.service.d.ts +13 -1
  166. package/dist/modules/data-table/data-table.service.js +13 -1
  167. package/dist/modules/data-table/data-table.service.js.map +1 -1
  168. package/dist/modules/data-table/errors/data-table-column-not-found.error.d.ts +2 -2
  169. package/dist/modules/data-table/errors/data-table-column-not-found.error.js +3 -5
  170. package/dist/modules/data-table/errors/data-table-column-not-found.error.js.map +1 -1
  171. package/dist/modules/data-table/errors/data-table-not-found.error.d.ts +2 -2
  172. package/dist/modules/data-table/errors/data-table-not-found.error.js +3 -5
  173. package/dist/modules/data-table/errors/data-table-not-found.error.js.map +1 -1
  174. package/dist/modules/data-table/utils/sql-utils.d.ts +1 -0
  175. package/dist/modules/data-table/utils/sql-utils.js +10 -0
  176. package/dist/modules/data-table/utils/sql-utils.js.map +1 -1
  177. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/bearer-token-extractor.d.ts +9 -0
  178. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/bearer-token-extractor.js +42 -0
  179. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/bearer-token-extractor.js.map +1 -0
  180. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/http-header-extractor.d.ts +9 -0
  181. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/http-header-extractor.js +141 -0
  182. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/http-header-extractor.js.map +1 -0
  183. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/index.d.ts +2 -0
  184. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/index.js +5 -0
  185. package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/index.js.map +1 -0
  186. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/identifier-interface.d.ts +7 -0
  187. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/identifier-interface.js +7 -0
  188. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/identifier-interface.js.map +1 -0
  189. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.d.ts +78 -0
  190. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js +223 -0
  191. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js.map +1 -0
  192. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.d.ts +37 -0
  193. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js +160 -0
  194. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js.map +1 -0
  195. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-utils.d.ts +13 -0
  196. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-utils.js +17 -0
  197. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-utils.js.map +1 -0
  198. package/dist/modules/dynamic-credentials.ee/credential-resolvers/index.d.ts +2 -0
  199. package/dist/modules/dynamic-credentials.ee/credential-resolvers/index.js +5 -0
  200. package/dist/modules/dynamic-credentials.ee/credential-resolvers/index.js.map +1 -0
  201. package/dist/modules/dynamic-credentials.ee/credential-resolvers/oauth-credential-resolver.d.ts +103 -0
  202. package/dist/modules/dynamic-credentials.ee/credential-resolvers/oauth-credential-resolver.js +174 -0
  203. package/dist/modules/dynamic-credentials.ee/credential-resolvers/oauth-credential-resolver.js.map +1 -0
  204. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-entry-storage.d.ts +9 -0
  205. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-entry-storage.js +56 -0
  206. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-entry-storage.js.map +1 -0
  207. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/storage-interface.d.ts +5 -0
  208. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/storage-interface.js +3 -0
  209. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/storage-interface.js.map +1 -0
  210. package/dist/modules/dynamic-credentials.ee/credential-resolvers/stub-credential-resolver.d.ts +28 -0
  211. package/dist/modules/dynamic-credentials.ee/credential-resolvers/stub-credential-resolver.js +86 -0
  212. package/dist/modules/dynamic-credentials.ee/credential-resolvers/stub-credential-resolver.js.map +1 -0
  213. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.d.ts +16 -0
  214. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js +172 -0
  215. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js.map +1 -0
  216. package/dist/modules/dynamic-credentials.ee/database/entities/credential-resolver.d.ts +8 -0
  217. package/dist/modules/dynamic-credentials.ee/database/entities/credential-resolver.js +33 -0
  218. package/dist/modules/dynamic-credentials.ee/database/entities/credential-resolver.js.map +1 -0
  219. package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-entry.d.ts +11 -0
  220. package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-entry.js +60 -0
  221. package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-entry.js.map +1 -0
  222. package/dist/modules/dynamic-credentials.ee/database/repositories/credential-resolver.repository.d.ts +5 -0
  223. package/dist/modules/dynamic-credentials.ee/database/repositories/credential-resolver.repository.js +26 -0
  224. package/dist/modules/dynamic-credentials.ee/database/repositories/credential-resolver.repository.js.map +1 -0
  225. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-entry.repository.d.ts +5 -0
  226. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-entry.repository.js +26 -0
  227. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-entry.repository.js.map +1 -0
  228. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.d.ts +9 -0
  229. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js +61 -0
  230. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js.map +1 -0
  231. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.d.ts +6 -0
  232. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js +91 -0
  233. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js.map +1 -0
  234. package/dist/modules/dynamic-credentials.ee/errors/credential-resolution.error.d.ts +6 -0
  235. package/dist/modules/dynamic-credentials.ee/errors/credential-resolution.error.js +12 -0
  236. package/dist/modules/dynamic-credentials.ee/errors/credential-resolution.error.js.map +1 -0
  237. package/dist/modules/dynamic-credentials.ee/errors/credential-resolver-not-found.error.d.ts +4 -0
  238. package/dist/modules/dynamic-credentials.ee/errors/credential-resolver-not-found.error.js +11 -0
  239. package/dist/modules/dynamic-credentials.ee/errors/credential-resolver-not-found.error.js.map +1 -0
  240. package/dist/modules/dynamic-credentials.ee/errors/credential-storage.error.d.ts +6 -0
  241. package/dist/modules/dynamic-credentials.ee/errors/credential-storage.error.js +12 -0
  242. package/dist/modules/dynamic-credentials.ee/errors/credential-storage.error.js.map +1 -0
  243. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-registry.service.d.ts +11 -0
  244. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-registry.service.js +64 -0
  245. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-registry.service.js.map +1 -0
  246. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.d.ts +22 -0
  247. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js +150 -0
  248. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -0
  249. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.d.ts +33 -0
  250. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js +118 -0
  251. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js.map +1 -0
  252. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.d.ts +18 -0
  253. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +94 -0
  254. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -0
  255. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.d.ts +20 -0
  256. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js +146 -0
  257. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -0
  258. package/dist/modules/dynamic-credentials.ee/services/index.d.ts +5 -0
  259. package/dist/modules/dynamic-credentials.ee/services/index.js +22 -0
  260. package/dist/modules/dynamic-credentials.ee/services/index.js.map +1 -0
  261. package/dist/modules/dynamic-credentials.ee/services/shared-fields.d.ts +2 -0
  262. package/dist/modules/dynamic-credentials.ee/services/shared-fields.js +13 -0
  263. package/dist/modules/dynamic-credentials.ee/services/shared-fields.js.map +1 -0
  264. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.d.ts +8 -0
  265. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js +62 -0
  266. package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js.map +1 -0
  267. package/dist/modules/external-secrets.ee/external-secrets-manager.ee.js +40 -24
  268. package/dist/modules/external-secrets.ee/external-secrets-manager.ee.js.map +1 -1
  269. package/dist/modules/insights/database/repositories/insights-by-period.repository.d.ts +2 -2
  270. package/dist/modules/insights/insights-collection.service.d.ts +2 -0
  271. package/dist/modules/insights/insights-collection.service.js +30 -6
  272. package/dist/modules/insights/insights-collection.service.js.map +1 -1
  273. package/dist/modules/insights/insights.service.d.ts +1 -1
  274. package/dist/modules/workflow-index/workflow-index.service.js +17 -10
  275. package/dist/modules/workflow-index/workflow-index.service.js.map +1 -1
  276. package/dist/oauth/oauth.service.d.ts +52 -0
  277. package/dist/oauth/oauth.service.js +417 -0
  278. package/dist/oauth/oauth.service.js.map +1 -0
  279. package/dist/oauth/types.d.ts +28 -0
  280. package/dist/oauth/types.js +16 -0
  281. package/dist/oauth/types.js.map +1 -0
  282. package/dist/public-api/v1/handlers/credentials/credentials.service.js +6 -8
  283. package/dist/public-api/v1/handlers/credentials/credentials.service.js.map +1 -1
  284. package/dist/public-api/v1/handlers/workflows/workflows.handler.js +2 -1
  285. package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
  286. package/dist/public-api/v1/openapi.yml +4 -0
  287. package/dist/requests.d.ts +1 -0
  288. package/dist/scaling/job-processor.js +8 -2
  289. package/dist/scaling/job-processor.js.map +1 -1
  290. package/dist/scaling/worker-status.service.ee.js +20 -2
  291. package/dist/scaling/worker-status.service.ee.js.map +1 -1
  292. package/dist/server.js +5 -3
  293. package/dist/server.js.map +1 -1
  294. package/dist/services/ai-workflow-builder.service.d.ts +1 -0
  295. package/dist/services/ai-workflow-builder.service.js +5 -3
  296. package/dist/services/ai-workflow-builder.service.js.map +1 -1
  297. package/dist/services/ai.service.js +3 -0
  298. package/dist/services/ai.service.js.map +1 -1
  299. package/dist/services/cache/cache.service.d.ts +1 -0
  300. package/dist/services/cache/cache.service.js +4 -0
  301. package/dist/services/cache/cache.service.js.map +1 -1
  302. package/dist/services/frontend.service.d.ts +6 -4
  303. package/dist/services/frontend.service.js +14 -9
  304. package/dist/services/frontend.service.js.map +1 -1
  305. package/dist/services/ownership.service.d.ts +13 -3
  306. package/dist/services/ownership.service.js +59 -4
  307. package/dist/services/ownership.service.js.map +1 -1
  308. package/dist/services/project.service.ee.js +1 -1
  309. package/dist/services/project.service.ee.js.map +1 -1
  310. package/dist/services/public-api-key.service.d.ts +1 -0
  311. package/dist/services/public-api-key.service.js +8 -0
  312. package/dist/services/public-api-key.service.js.map +1 -1
  313. package/dist/services/user.service.d.ts +4 -3
  314. package/dist/services/user.service.js +50 -4
  315. package/dist/services/user.service.js.map +1 -1
  316. package/dist/telemetry/index.js +1 -0
  317. package/dist/telemetry/index.js.map +1 -1
  318. package/dist/webhooks/test-webhook-registrations.service.d.ts +5 -3
  319. package/dist/webhooks/test-webhook-registrations.service.js +25 -6
  320. package/dist/webhooks/test-webhook-registrations.service.js.map +1 -1
  321. package/dist/webhooks/test-webhooks.d.ts +1 -0
  322. package/dist/webhooks/test-webhooks.js +17 -10
  323. package/dist/webhooks/test-webhooks.js.map +1 -1
  324. package/dist/webhooks/waiting-forms.js +2 -0
  325. package/dist/webhooks/waiting-forms.js.map +1 -1
  326. package/dist/webhooks/webhook-helpers.js +12 -3
  327. package/dist/webhooks/webhook-helpers.js.map +1 -1
  328. package/dist/workflow-execute-additional-data.d.ts +2 -1
  329. package/dist/workflow-execute-additional-data.js +5 -3
  330. package/dist/workflow-execute-additional-data.js.map +1 -1
  331. package/dist/workflow-runner.js +1 -0
  332. package/dist/workflow-runner.js.map +1 -1
  333. package/dist/workflows/workflow-execution.service.js +3 -0
  334. package/dist/workflows/workflow-execution.service.js.map +1 -1
  335. package/dist/workflows/workflow-history/workflow-history.service.d.ts +1 -1
  336. package/dist/workflows/workflow-history/workflow-history.service.js +2 -1
  337. package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
  338. package/dist/workflows/workflow.request.d.ts +2 -0
  339. package/dist/workflows/workflow.service.d.ts +2 -0
  340. package/dist/workflows/workflow.service.js +4 -2
  341. package/dist/workflows/workflow.service.js.map +1 -1
  342. package/dist/workflows/workflows.controller.js +13 -11
  343. package/dist/workflows/workflows.controller.js.map +1 -1
  344. package/package.json +19 -19
  345. package/templates/form-trigger-completion.handlebars +1 -4
  346. package/templates/form-trigger.handlebars +1 -2
  347. package/dist/controllers/oauth/abstract-oauth.controller.d.ts +0 -47
  348. package/dist/controllers/oauth/abstract-oauth.controller.js +0 -185
  349. package/dist/controllers/oauth/abstract-oauth.controller.js.map +0 -1
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ChatHubService = void 0;
13
13
  const api_types_1 = require("@n8n/api-types");
14
14
  const backend_common_1 = require("@n8n/backend-common");
15
+ const config_1 = require("@n8n/config");
15
16
  const db_1 = require("@n8n/db");
16
17
  const di_1 = require("@n8n/di");
17
18
  const n8n_core_1 = require("n8n-core");
@@ -27,682 +28,32 @@ const chat_message_repository_1 = require("./chat-message.repository");
27
28
  const chat_session_repository_1 = require("./chat-session.repository");
28
29
  const stream_capturer_1 = require("./stream-capturer");
29
30
  const active_executions_1 = require("../../active-executions");
30
- const credentials_finder_service_1 = require("../../credentials/credentials-finder.service");
31
31
  const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
32
32
  const not_found_error_1 = require("../../errors/response-errors/not-found.error");
33
33
  const execution_service_1 = require("../../executions/execution.service");
34
- const dynamic_node_parameters_service_1 = require("../../services/dynamic-node-parameters.service");
35
- const workflow_execute_additional_data_1 = require("../../workflow-execute-additional-data");
36
34
  const workflow_execution_service_1 = require("../../workflows/workflow-execution.service");
37
35
  const workflow_finder_service_1 = require("../../workflows/workflow-finder.service");
38
- const workflow_service_1 = require("../../workflows/workflow.service");
36
+ const chat_hub_models_service_1 = require("./chat-hub.models.service");
39
37
  let ChatHubService = class ChatHubService {
40
- constructor(logger, errorReporter, executionService, nodeParametersService, executionRepository, workflowExecutionService, workflowService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, credentialsFinderService, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService, chatHubSettingsService, chatHubAttachmentService) {
38
+ constructor(logger, errorReporter, executionService, executionRepository, workflowExecutionService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService, chatHubModelsService, chatHubSettingsService, chatHubAttachmentService, instanceSettings, globalConfig) {
41
39
  this.logger = logger;
42
40
  this.errorReporter = errorReporter;
43
41
  this.executionService = executionService;
44
- this.nodeParametersService = nodeParametersService;
45
42
  this.executionRepository = executionRepository;
46
43
  this.workflowExecutionService = workflowExecutionService;
47
- this.workflowService = workflowService;
48
44
  this.workflowFinderService = workflowFinderService;
49
45
  this.workflowRepository = workflowRepository;
50
46
  this.activeExecutions = activeExecutions;
51
47
  this.sessionRepository = sessionRepository;
52
48
  this.messageRepository = messageRepository;
53
- this.credentialsFinderService = credentialsFinderService;
54
49
  this.chatHubAgentService = chatHubAgentService;
55
50
  this.chatHubCredentialsService = chatHubCredentialsService;
56
51
  this.chatHubWorkflowService = chatHubWorkflowService;
52
+ this.chatHubModelsService = chatHubModelsService;
57
53
  this.chatHubSettingsService = chatHubSettingsService;
58
54
  this.chatHubAttachmentService = chatHubAttachmentService;
59
- }
60
- async getModels(user, credentialIds) {
61
- const additionalData = await (0, workflow_execute_additional_data_1.getBase)({ userId: user.id });
62
- const providers = api_types_1.chatHubProviderSchema.options;
63
- const allCredentials = await this.credentialsFinderService.findCredentialsForUser(user, [
64
- 'credential:read',
65
- ]);
66
- const responses = await Promise.all(providers.map(async (provider) => {
67
- const credentials = {};
68
- if (provider !== 'n8n' && provider !== 'custom-agent') {
69
- const credentialId = credentialIds[provider];
70
- if (!credentialId) {
71
- return [provider, { models: [] }];
72
- }
73
- if (!allCredentials.some((credential) => credential.id === credentialId)) {
74
- return [
75
- provider,
76
- { models: [], error: 'Could not retrieve models. Verify credentials.' },
77
- ];
78
- }
79
- credentials[api_types_1.PROVIDER_CREDENTIAL_TYPE_MAP[provider]] = { name: '', id: credentialId };
80
- }
81
- try {
82
- return [
83
- provider,
84
- await this.fetchModelsForProvider(user, provider, credentials, additionalData),
85
- ];
86
- }
87
- catch {
88
- return [
89
- provider,
90
- { models: [], error: 'Could not retrieve models. Verify credentials.' },
91
- ];
92
- }
93
- }));
94
- return responses.reduce((acc, [provider, res]) => {
95
- acc[provider] = res;
96
- return acc;
97
- }, { ...api_types_1.emptyChatModelsResponse });
98
- }
99
- async fetchModelsForProvider(user, provider, credentials, additionalData) {
100
- switch (provider) {
101
- case 'openai':
102
- return await this.fetchOpenAiModels(credentials, additionalData);
103
- case 'anthropic':
104
- return await this.fetchAnthropicModels(credentials, additionalData);
105
- case 'google':
106
- return await this.fetchGoogleModels(credentials, additionalData);
107
- case 'ollama':
108
- return await this.fetchOllamaModels(credentials, additionalData);
109
- case 'azureOpenAi':
110
- case 'azureEntraId':
111
- return this.fetchAzureOpenAiModels(credentials, additionalData);
112
- case 'awsBedrock':
113
- return await this.fetchAwsBedrockModels(credentials, additionalData);
114
- case 'vercelAiGateway':
115
- return await this.fetchVercelAiGatewayModels(credentials, additionalData);
116
- case 'xAiGrok':
117
- return await this.fetchXAiGrokModels(credentials, additionalData);
118
- case 'groq':
119
- return await this.fetchGroqModels(credentials, additionalData);
120
- case 'openRouter':
121
- return await this.fetchOpenRouterModels(credentials, additionalData);
122
- case 'deepSeek':
123
- return await this.fetchDeepSeekModels(credentials, additionalData);
124
- case 'cohere':
125
- return await this.fetchCohereModels(credentials, additionalData);
126
- case 'mistralCloud':
127
- return await this.fetchMistralCloudModels(credentials, additionalData);
128
- case 'n8n':
129
- return await this.fetchAgentWorkflowsAsModels(user);
130
- case 'custom-agent':
131
- return await this.chatHubAgentService.getAgentsByUserIdAsModels(user.id);
132
- }
133
- }
134
- async fetchOpenAiModels(credentials, additionalData) {
135
- const resourceLocatorResults = await this.nodeParametersService.getResourceLocatorResults('searchModels', 'parameters.model', additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.openai, {}, credentials);
136
- return {
137
- models: resourceLocatorResults.results.map((result) => ({
138
- name: result.name,
139
- description: result.description ?? null,
140
- model: {
141
- provider: 'openai',
142
- model: String(result.value),
143
- },
144
- createdAt: null,
145
- updatedAt: null,
146
- allowFileUploads: true,
147
- })),
148
- };
149
- }
150
- async fetchAnthropicModels(credentials, additionalData) {
151
- const resourceLocatorResults = await this.nodeParametersService.getResourceLocatorResults('searchModels', 'parameters.model', additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.anthropic, {}, credentials);
152
- return {
153
- models: resourceLocatorResults.results.map((result) => ({
154
- name: result.name,
155
- description: result.description ?? null,
156
- model: {
157
- provider: 'anthropic',
158
- model: String(result.value),
159
- },
160
- createdAt: null,
161
- updatedAt: null,
162
- allowFileUploads: true,
163
- })),
164
- };
165
- }
166
- async fetchGoogleModels(credentials, additionalData) {
167
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
168
- routing: {
169
- request: {
170
- method: 'GET',
171
- url: '/v1beta/models',
172
- },
173
- output: {
174
- postReceive: [
175
- {
176
- type: 'rootProperty',
177
- properties: {
178
- property: 'models',
179
- },
180
- },
181
- {
182
- type: 'filter',
183
- properties: {
184
- pass: "={{ !$responseItem.name.includes('embedding') }}",
185
- },
186
- },
187
- {
188
- type: 'setKeyValue',
189
- properties: {
190
- name: '={{$responseItem.name}}',
191
- value: '={{$responseItem.name}}',
192
- description: '={{$responseItem.description}}',
193
- },
194
- },
195
- {
196
- type: 'sort',
197
- properties: {
198
- key: 'name',
199
- },
200
- },
201
- ],
202
- },
203
- },
204
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.google, {}, credentials);
205
- return {
206
- models: results.map((result) => ({
207
- name: result.name,
208
- description: result.description ?? null,
209
- model: {
210
- provider: 'google',
211
- model: String(result.value),
212
- },
213
- createdAt: null,
214
- updatedAt: null,
215
- allowFileUploads: true,
216
- })),
217
- };
218
- }
219
- async fetchOllamaModels(credentials, additionalData) {
220
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
221
- routing: {
222
- request: {
223
- method: 'GET',
224
- url: '/api/tags',
225
- },
226
- output: {
227
- postReceive: [
228
- {
229
- type: 'rootProperty',
230
- properties: {
231
- property: 'models',
232
- },
233
- },
234
- {
235
- type: 'setKeyValue',
236
- properties: {
237
- name: '={{$responseItem.name}}',
238
- value: '={{$responseItem.name}}',
239
- },
240
- },
241
- {
242
- type: 'sort',
243
- properties: {
244
- key: 'name',
245
- },
246
- },
247
- ],
248
- },
249
- },
250
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.ollama, {}, credentials);
251
- return {
252
- models: results.map((result) => ({
253
- name: result.name,
254
- description: result.description ?? null,
255
- model: {
256
- provider: 'ollama',
257
- model: String(result.value),
258
- },
259
- createdAt: null,
260
- updatedAt: null,
261
- allowFileUploads: true,
262
- })),
263
- };
264
- }
265
- fetchAzureOpenAiModels(_credentials, _additionalData) {
266
- return {
267
- models: [],
268
- };
269
- }
270
- async fetchAwsBedrockModels(credentials, additionalData) {
271
- const foundationModelsRequest = this.nodeParametersService.getOptionsViaLoadOptions({
272
- routing: {
273
- request: {
274
- method: 'GET',
275
- url: '/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND',
276
- },
277
- output: {
278
- postReceive: [
279
- {
280
- type: 'rootProperty',
281
- properties: {
282
- property: 'modelSummaries',
283
- },
284
- },
285
- {
286
- type: 'setKeyValue',
287
- properties: {
288
- name: '={{$responseItem.modelName}}',
289
- description: '={{$responseItem.modelArn}}',
290
- value: '={{$responseItem.modelId}}',
291
- },
292
- },
293
- {
294
- type: 'sort',
295
- properties: {
296
- key: 'name',
297
- },
298
- },
299
- ],
300
- },
301
- },
302
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.awsBedrock, {}, credentials);
303
- const inferenceProfileModelsRequest = this.nodeParametersService.getOptionsViaLoadOptions({
304
- routing: {
305
- request: {
306
- method: 'GET',
307
- url: '/inference-profiles?maxResults=1000',
308
- },
309
- output: {
310
- postReceive: [
311
- {
312
- type: 'rootProperty',
313
- properties: {
314
- property: 'inferenceProfileSummaries',
315
- },
316
- },
317
- {
318
- type: 'setKeyValue',
319
- properties: {
320
- name: '={{$responseItem.inferenceProfileName}}',
321
- description: '={{$responseItem.description || $responseItem.inferenceProfileArn}}',
322
- value: '={{$responseItem.inferenceProfileId}}',
323
- },
324
- },
325
- {
326
- type: 'sort',
327
- properties: {
328
- key: 'name',
329
- },
330
- },
331
- ],
332
- },
333
- },
334
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.awsBedrock, {}, credentials);
335
- const [foundationModels, inferenceProfileModels] = await Promise.all([
336
- foundationModelsRequest,
337
- inferenceProfileModelsRequest,
338
- ]);
339
- return {
340
- models: foundationModels.concat(inferenceProfileModels).map((result) => ({
341
- name: result.name,
342
- description: result.description ?? String(result.value),
343
- model: {
344
- provider: 'awsBedrock',
345
- model: String(result.value),
346
- },
347
- createdAt: null,
348
- updatedAt: null,
349
- allowFileUploads: true,
350
- })),
351
- };
352
- }
353
- async fetchMistralCloudModels(credentials, additionalData) {
354
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
355
- routing: {
356
- request: {
357
- method: 'GET',
358
- url: '/models',
359
- },
360
- output: {
361
- postReceive: [
362
- {
363
- type: 'rootProperty',
364
- properties: {
365
- property: 'data',
366
- },
367
- },
368
- {
369
- type: 'filter',
370
- properties: {
371
- pass: "={{ !$responseItem.id.includes('embed') }}",
372
- },
373
- },
374
- {
375
- type: 'setKeyValue',
376
- properties: {
377
- name: '={{ $responseItem.id }}',
378
- value: '={{ $responseItem.id }}',
379
- },
380
- },
381
- {
382
- type: 'sort',
383
- properties: {
384
- key: 'name',
385
- },
386
- },
387
- ],
388
- },
389
- },
390
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.mistralCloud, {}, credentials);
391
- return {
392
- models: results.map((result) => ({
393
- name: result.name,
394
- description: result.description ?? String(result.value),
395
- model: {
396
- provider: 'mistralCloud',
397
- model: String(result.value),
398
- },
399
- createdAt: null,
400
- updatedAt: null,
401
- })),
402
- };
403
- }
404
- async fetchCohereModels(credentials, additionalData) {
405
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
406
- routing: {
407
- request: {
408
- method: 'GET',
409
- url: '/v1/models?page_size=100&endpoint=chat',
410
- },
411
- output: {
412
- postReceive: [
413
- {
414
- type: 'rootProperty',
415
- properties: {
416
- property: 'models',
417
- },
418
- },
419
- {
420
- type: 'setKeyValue',
421
- properties: {
422
- name: '={{$responseItem.name}}',
423
- value: '={{$responseItem.name}}',
424
- description: '={{$responseItem.description}}',
425
- },
426
- },
427
- {
428
- type: 'sort',
429
- properties: {
430
- key: 'name',
431
- },
432
- },
433
- ],
434
- },
435
- },
436
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.cohere, {}, credentials);
437
- return {
438
- models: results.map((result) => ({
439
- name: result.name,
440
- description: result.description ?? null,
441
- model: {
442
- provider: 'cohere',
443
- model: String(result.value),
444
- },
445
- createdAt: null,
446
- updatedAt: null,
447
- })),
448
- };
449
- }
450
- async fetchDeepSeekModels(credentials, additionalData) {
451
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
452
- routing: {
453
- request: {
454
- method: 'GET',
455
- url: '/models',
456
- },
457
- output: {
458
- postReceive: [
459
- {
460
- type: 'rootProperty',
461
- properties: {
462
- property: 'data',
463
- },
464
- },
465
- {
466
- type: 'setKeyValue',
467
- properties: {
468
- name: '={{$responseItem.id}}',
469
- value: '={{$responseItem.id}}',
470
- },
471
- },
472
- {
473
- type: 'sort',
474
- properties: {
475
- key: 'name',
476
- },
477
- },
478
- ],
479
- },
480
- },
481
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.deepSeek, {}, credentials);
482
- return {
483
- models: results.map((result) => ({
484
- name: result.name,
485
- description: result.description ?? String(result.value),
486
- model: {
487
- provider: 'deepSeek',
488
- model: String(result.value),
489
- },
490
- createdAt: null,
491
- updatedAt: null,
492
- })),
493
- };
494
- }
495
- async fetchOpenRouterModels(credentials, additionalData) {
496
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
497
- routing: {
498
- request: {
499
- method: 'GET',
500
- url: '/models',
501
- },
502
- output: {
503
- postReceive: [
504
- {
505
- type: 'rootProperty',
506
- properties: {
507
- property: 'data',
508
- },
509
- },
510
- {
511
- type: 'setKeyValue',
512
- properties: {
513
- name: '={{$responseItem.id}}',
514
- value: '={{$responseItem.id}}',
515
- },
516
- },
517
- {
518
- type: 'sort',
519
- properties: {
520
- key: 'name',
521
- },
522
- },
523
- ],
524
- },
525
- },
526
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.openRouter, {}, credentials);
527
- return {
528
- models: results.map((result) => ({
529
- name: result.name,
530
- description: result.description ?? null,
531
- model: {
532
- provider: 'openRouter',
533
- model: String(result.value),
534
- },
535
- createdAt: null,
536
- updatedAt: null,
537
- })),
538
- };
539
- }
540
- async fetchGroqModels(credentials, additionalData) {
541
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
542
- routing: {
543
- request: {
544
- method: 'GET',
545
- url: '/models',
546
- },
547
- output: {
548
- postReceive: [
549
- {
550
- type: 'rootProperty',
551
- properties: {
552
- property: 'data',
553
- },
554
- },
555
- {
556
- type: 'filter',
557
- properties: {
558
- pass: '={{ $responseItem.active === true && $responseItem.object === "model" }}',
559
- },
560
- },
561
- {
562
- type: 'setKeyValue',
563
- properties: {
564
- name: '={{$responseItem.id}}',
565
- value: '={{$responseItem.id}}',
566
- },
567
- },
568
- ],
569
- },
570
- },
571
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.groq, {}, credentials);
572
- return {
573
- models: results.map((result) => ({
574
- name: result.name,
575
- description: result.description ?? null,
576
- model: {
577
- provider: 'groq',
578
- model: String(result.value),
579
- },
580
- createdAt: null,
581
- updatedAt: null,
582
- })),
583
- };
584
- }
585
- async fetchXAiGrokModels(credentials, additionalData) {
586
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
587
- routing: {
588
- request: {
589
- method: 'GET',
590
- url: '/models',
591
- },
592
- output: {
593
- postReceive: [
594
- {
595
- type: 'rootProperty',
596
- properties: {
597
- property: 'data',
598
- },
599
- },
600
- {
601
- type: 'setKeyValue',
602
- properties: {
603
- name: '={{$responseItem.id}}',
604
- value: '={{$responseItem.id}}',
605
- },
606
- },
607
- {
608
- type: 'sort',
609
- properties: {
610
- key: 'name',
611
- },
612
- },
613
- ],
614
- },
615
- },
616
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.xAiGrok, {}, credentials);
617
- return {
618
- models: results.map((result) => ({
619
- name: result.name,
620
- description: result.description ?? null,
621
- model: {
622
- provider: 'xAiGrok',
623
- model: String(result.value),
624
- },
625
- createdAt: null,
626
- updatedAt: null,
627
- })),
628
- };
629
- }
630
- async fetchVercelAiGatewayModels(credentials, additionalData) {
631
- const results = await this.nodeParametersService.getOptionsViaLoadOptions({
632
- routing: {
633
- request: {
634
- method: 'GET',
635
- url: '/models',
636
- },
637
- output: {
638
- postReceive: [
639
- {
640
- type: 'rootProperty',
641
- properties: {
642
- property: 'data',
643
- },
644
- },
645
- {
646
- type: 'setKeyValue',
647
- properties: {
648
- name: '={{$responseItem.id}}',
649
- value: '={{$responseItem.id}}',
650
- },
651
- },
652
- {
653
- type: 'sort',
654
- properties: {
655
- key: 'name',
656
- },
657
- },
658
- ],
659
- },
660
- },
661
- }, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.vercelAiGateway, {}, credentials);
662
- return {
663
- models: results.map((result) => ({
664
- name: result.name,
665
- description: result.description ?? String(result.value),
666
- model: {
667
- provider: 'vercelAiGateway',
668
- model: String(result.value),
669
- },
670
- createdAt: null,
671
- updatedAt: null,
672
- })),
673
- };
674
- }
675
- async fetchAgentWorkflowsAsModels(user) {
676
- const nodeTypes = [n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE];
677
- const workflows = await this.workflowService.getWorkflowsWithNodesIncluded(user, nodeTypes, true);
678
- return {
679
- models: workflows
680
- .filter((workflow) => workflow.scopes.includes('workflow:read'))
681
- .filter((workflow) => !!workflow.activeVersionId)
682
- .flatMap((workflow) => {
683
- const chatTrigger = workflow.nodes?.find((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
684
- if (!chatTrigger) {
685
- return [];
686
- }
687
- const chatTriggerParams = chat_hub_types_1.validChatTriggerParamsShape.safeParse(chatTrigger.parameters).data;
688
- if (!chatTriggerParams) {
689
- return [];
690
- }
691
- return [
692
- {
693
- name: chatTriggerParams.agentName ?? workflow.name ?? 'Unknown Agent',
694
- description: chatTriggerParams.agentDescription ?? null,
695
- model: {
696
- provider: 'n8n',
697
- workflowId: workflow.id,
698
- },
699
- createdAt: workflow.createdAt ? workflow.createdAt.toISOString() : null,
700
- updatedAt: workflow.updatedAt ? workflow.updatedAt.toISOString() : null,
701
- allowFileUploads: chatTriggerParams.options?.allowFileUploads ?? false,
702
- },
703
- ];
704
- }),
705
- };
55
+ this.instanceSettings = instanceSettings;
56
+ this.globalConfig = globalConfig;
706
57
  }
707
58
  async deleteChatWorkflow(workflowId) {
708
59
  await this.workflowRepository.delete(workflowId);
@@ -737,11 +88,13 @@ let ChatHubService = class ChatHubService {
737
88
  return credentials[api_types_1.PROVIDER_CREDENTIAL_TYPE_MAP[provider]]?.id ?? null;
738
89
  }
739
90
  async sendHumanMessage(res, user, payload) {
740
- const { sessionId, messageId, message, model, credentials, previousMessageId, tools, attachments, } = payload;
91
+ const { sessionId, messageId, message, model, credentials, previousMessageId, tools, attachments, timeZone, } = payload;
92
+ const tz = timeZone ?? this.globalConfig.generic.timezone;
741
93
  const credentialId = this.getModelCredential(model, credentials);
742
94
  const processedAttachments = await this.chatHubAttachmentService.store(sessionId, messageId, attachments);
743
95
  let executionData;
744
96
  let workflowData;
97
+ let responseMode;
745
98
  try {
746
99
  const result = await this.messageRepository.manager.transaction(async (trx) => {
747
100
  let session = await this.getChatSession(user, sessionId, trx);
@@ -750,10 +103,11 @@ let ChatHubService = class ChatHubService {
750
103
  const messages = Object.fromEntries((session.messages ?? []).map((m) => [m.id, m]));
751
104
  const history = this.buildMessageHistory(messages, previousMessageId);
752
105
  await this.saveHumanMessage(payload, processedAttachments, user, previousMessageId, model, undefined, trx);
753
- return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, processedAttachments, trx);
106
+ return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, processedAttachments, tz, trx);
754
107
  });
755
108
  executionData = result.executionData;
756
109
  workflowData = result.workflowData;
110
+ responseMode = result.responseMode;
757
111
  }
758
112
  catch (error) {
759
113
  if (processedAttachments.length > 0) {
@@ -766,15 +120,16 @@ let ChatHubService = class ChatHubService {
766
120
  }
767
121
  throw error;
768
122
  }
769
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model);
123
+ await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model, null, responseMode);
770
124
  if (previousMessageId === null) {
771
- await this.generateSessionTitle(user, sessionId, message, credentials, model).catch((error) => {
125
+ await this.generateSessionTitle(user, sessionId, message, processedAttachments, credentials, model).catch((error) => {
772
126
  this.logger.error(`Title generation failed: ${error}`);
773
127
  });
774
128
  }
775
129
  }
776
130
  async editMessage(res, user, payload) {
777
- const { sessionId, editId, messageId, message, model, credentials } = payload;
131
+ const { sessionId, editId, messageId, message, model, credentials, timeZone } = payload;
132
+ const tz = timeZone ?? this.globalConfig.generic.timezone;
778
133
  const workflow = await this.messageRepository.manager.transaction(async (trx) => {
779
134
  const session = await this.getChatSession(user, sessionId, trx);
780
135
  if (!session) {
@@ -791,19 +146,20 @@ let ChatHubService = class ChatHubService {
791
146
  const revisionOfMessageId = messageToEdit.revisionOfMessageId ?? messageToEdit.id;
792
147
  const attachments = messageToEdit.attachments ?? [];
793
148
  await this.saveHumanMessage(payload, attachments, user, messageToEdit.previousMessageId, model, revisionOfMessageId, trx);
794
- return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, trx);
149
+ return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, tz, trx);
795
150
  }
796
151
  throw new bad_request_error_1.BadRequestError('Only human and AI messages can be edited');
797
152
  });
798
153
  if (!workflow) {
799
154
  return;
800
155
  }
801
- const { workflowData, executionData } = workflow;
802
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model);
156
+ const { workflowData, executionData, responseMode } = workflow;
157
+ await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model, null, responseMode);
803
158
  }
804
159
  async regenerateAIMessage(res, user, payload) {
805
- const { sessionId, retryId, model, credentials } = payload;
806
- const { workflow: { workflowData, executionData }, retryOfMessageId, previousMessageId, } = await this.messageRepository.manager.transaction(async (trx) => {
160
+ const { sessionId, retryId, model, credentials, timeZone } = payload;
161
+ const tz = timeZone ?? this.globalConfig.generic.timezone;
162
+ const { workflow: { workflowData, executionData, responseMode }, retryOfMessageId, previousMessageId, } = await this.messageRepository.manager.transaction(async (trx) => {
807
163
  const session = await this.getChatSession(user, sessionId, trx);
808
164
  if (!session) {
809
165
  throw new not_found_error_1.NotFoundError('Chat session not found');
@@ -825,30 +181,30 @@ let ChatHubService = class ChatHubService {
825
181
  const retryOfMessageId = messageToRetry.retryOfMessageId ?? messageToRetry.id;
826
182
  const message = lastHumanMessage ? lastHumanMessage.content : '';
827
183
  const attachments = lastHumanMessage.attachments ?? [];
828
- const workflow = await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, trx);
184
+ const workflow = await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, tz, trx);
829
185
  return {
830
186
  workflow,
831
187
  previousMessageId: lastHumanMessage.id,
832
188
  retryOfMessageId,
833
189
  };
834
190
  });
835
- await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId);
191
+ await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, responseMode);
836
192
  }
837
- async prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, attachments, trx) {
193
+ async prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, attachments, timeZone, trx) {
838
194
  if (model.provider === 'n8n') {
839
195
  return await this.prepareCustomAgentWorkflow(user, sessionId, model.workflowId, message, attachments);
840
196
  }
841
197
  if (model.provider === 'custom-agent') {
842
- return await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, attachments, trx);
198
+ return await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, attachments, timeZone, trx);
843
199
  }
844
- return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, undefined, tools, attachments, trx);
200
+ return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, undefined, tools, attachments, timeZone, trx);
845
201
  }
846
- async prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, trx) {
202
+ async prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, timeZone, trx) {
847
203
  await this.chatHubSettingsService.ensureModelIsAllowed(model);
848
204
  const credential = await this.chatHubCredentialsService.ensureCredentials(user, model.provider, credentials, trx);
849
- return await this.chatHubWorkflowService.createChatWorkflow(user.id, sessionId, credential.projectId, history, message, attachments, credentials, model, systemMessage, tools, trx);
205
+ return await this.chatHubWorkflowService.createChatWorkflow(user.id, sessionId, credential.projectId, history, message, attachments, credentials, model, systemMessage, tools, timeZone, trx);
850
206
  }
851
- async prepareChatAgentWorkflow(agentId, user, sessionId, history, message, attachments, trx) {
207
+ async prepareChatAgentWorkflow(agentId, user, sessionId, history, message, attachments, timeZone, trx) {
852
208
  const agent = await this.chatHubAgentService.getAgentById(agentId, user.id);
853
209
  if (!agent) {
854
210
  throw new bad_request_error_1.BadRequestError('Agent not found');
@@ -856,14 +212,11 @@ let ChatHubService = class ChatHubService {
856
212
  if (!agent.provider || !agent.model) {
857
213
  throw new bad_request_error_1.BadRequestError('Provider or model not set for agent');
858
214
  }
859
- if (agent.provider === 'n8n' || agent.provider === 'custom-agent') {
860
- throw new bad_request_error_1.BadRequestError('Invalid provider');
861
- }
862
215
  const credentialId = agent.credentialId;
863
216
  if (!credentialId) {
864
217
  throw new bad_request_error_1.BadRequestError('Credentials not set for agent');
865
218
  }
866
- const systemMessage = agent.systemPrompt;
219
+ const systemMessage = agent.systemPrompt + '\n\n' + this.chatHubWorkflowService.getSystemMessageMetadata(timeZone);
867
220
  const model = {
868
221
  provider: agent.provider,
869
222
  model: agent.model,
@@ -874,24 +227,42 @@ let ChatHubService = class ChatHubService {
874
227
  name: '',
875
228
  },
876
229
  };
877
- const tools = [];
878
- return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, trx);
230
+ const { tools } = agent;
231
+ return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, timeZone, trx);
879
232
  }
880
233
  async prepareCustomAgentWorkflow(user, sessionId, workflowId, message, attachments) {
881
- const workflowEntity = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:read'], { includeTags: false, includeParentFolder: false });
882
- if (!workflowEntity) {
234
+ const workflow = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true });
235
+ if (!workflow?.activeVersion) {
883
236
  throw new bad_request_error_1.BadRequestError('Workflow not found');
884
237
  }
885
- const chatTriggers = workflowEntity.nodes.filter((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
238
+ const chatTriggers = workflow.activeVersion.nodes.filter((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
886
239
  if (chatTriggers.length !== 1) {
887
240
  throw new bad_request_error_1.BadRequestError('Workflow must have exactly one chat trigger');
888
241
  }
889
- const chatTriggerNode = chatTriggers[0];
890
- const chatResponseNodes = workflowEntity.nodes.filter((node) => node.type === n8n_workflow_1.RESPOND_TO_CHAT_NODE_TYPE);
242
+ const chatTrigger = chatTriggers[0];
243
+ if (chatTrigger.typeVersion < chat_hub_constants_1.CHAT_TRIGGER_NODE_MIN_VERSION) {
244
+ throw new bad_request_error_1.BadRequestError('Chat Trigger node version is too old to support Chat. Please update the node.');
245
+ }
246
+ const chatTriggerParams = chat_hub_types_1.chatTriggerParamsShape.safeParse(chatTrigger.parameters).data;
247
+ if (!chatTriggerParams) {
248
+ throw new bad_request_error_1.BadRequestError('Chat Trigger node has invalid parameters');
249
+ }
250
+ if (!chatTriggerParams.availableInChat) {
251
+ throw new bad_request_error_1.BadRequestError('Chat Trigger node must be made available in Chat');
252
+ }
253
+ const responseMode = chatTriggerParams.options?.responseMode ?? 'streaming';
254
+ if (responseMode !== 'streaming') {
255
+ throw new bad_request_error_1.BadRequestError('Chat Trigger node response mode must be set to streaming to use the workflow on Chat');
256
+ }
257
+ const chatResponseNodes = workflow.activeVersion.nodes.filter((node) => node.type === n8n_workflow_1.RESPOND_TO_CHAT_NODE_TYPE);
891
258
  if (chatResponseNodes.length > 0) {
892
259
  throw new bad_request_error_1.BadRequestError('Respond to Chat nodes are not supported in custom agent workflows');
893
260
  }
894
- const nodeExecutionStack = this.chatHubWorkflowService.prepareExecutionData(chatTriggerNode, sessionId, message, attachments);
261
+ const agentNodes = workflow.activeVersion.nodes?.filter((node) => node.type === n8n_workflow_1.AGENT_LANGCHAIN_NODE_TYPE);
262
+ if (agentNodes.some((node) => node.typeVersion < chat_hub_constants_1.TOOLS_AGENT_NODE_MIN_VERSION)) {
263
+ throw new bad_request_error_1.BadRequestError('Agent node version is too old to support streaming responses. Please update the node.');
264
+ }
265
+ const nodeExecutionStack = this.chatHubWorkflowService.prepareExecutionData(chatTrigger, sessionId, message, attachments);
895
266
  const executionData = (0, n8n_workflow_1.createRunExecutionData)({
896
267
  executionData: {
897
268
  nodeExecutionStack,
@@ -900,11 +271,15 @@ let ChatHubService = class ChatHubService {
900
271
  userId: user.id,
901
272
  },
902
273
  });
274
+ const workflowData = {
275
+ ...workflow,
276
+ nodes: workflow.activeVersion.nodes,
277
+ connections: workflow.activeVersion.connections,
278
+ };
903
279
  return {
904
- workflowData: {
905
- ...workflowEntity,
906
- },
280
+ workflowData,
907
281
  executionData,
282
+ responseMode,
908
283
  };
909
284
  }
910
285
  async ensurePreviousMessage(previousMessageId, sessionId, trx) {
@@ -937,8 +312,11 @@ let ChatHubService = class ChatHubService {
937
312
  await this.executionService.stop(message.execution.id, [message.execution.workflowId]);
938
313
  await this.messageRepository.updateChatMessage(messageId, { status: 'cancelled' });
939
314
  }
940
- async executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId = null, executionMode = 'chat') {
315
+ async executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId = null, executionMode = 'chat', responseMode) {
941
316
  this.logger.debug(`Starting execution of workflow "${workflowData.name}" with ID ${workflowData.id}`);
317
+ if (responseMode !== 'streaming') {
318
+ throw new bad_request_error_1.BadRequestError(`Response mode "${responseMode}" is not supported yet.`);
319
+ }
942
320
  let executionId = undefined;
943
321
  const aggregator = (0, stream_capturer_1.createStructuredChunkAggregator)(previousMessageId, retryOfMessageId, {
944
322
  onBegin: async (message) => {
@@ -995,7 +373,7 @@ let ChatHubService = class ChatHubService {
995
373
  executionId: executionId ? +executionId : null,
996
374
  },
997
375
  };
998
- return JSON.stringify(enriched) + '\n';
376
+ return (0, n8n_workflow_1.jsonStringify)(enriched) + '\n';
999
377
  };
1000
378
  const stream = (0, stream_capturer_1.interceptResponseWrites)(res, transform);
1001
379
  stream.on('finish', aggregator.finalizeAll);
@@ -1007,6 +385,52 @@ let ChatHubService = class ChatHubService {
1007
385
  if (!executionId) {
1008
386
  throw new n8n_workflow_1.OperationalError('There was a problem starting the chat execution.');
1009
387
  }
388
+ await this.waitForExecutionCompletion(executionId);
389
+ }
390
+ async waitForExecutionCompletion(executionId) {
391
+ if (this.instanceSettings.isMultiMain) {
392
+ return await this.waitForExecutionPoller(executionId);
393
+ }
394
+ else {
395
+ return await this.waitForExecutionPromise(executionId);
396
+ }
397
+ }
398
+ async waitForExecutionPoller(executionId) {
399
+ return await new Promise((resolve, reject) => {
400
+ const poller = setInterval(async () => {
401
+ try {
402
+ const result = await this.executionRepository.findSingleExecution(executionId, {
403
+ includeData: false,
404
+ unflattenData: false,
405
+ });
406
+ if (!result || chat_hub_constants_1.EXECUTION_FINISHED_STATUSES.includes(result.status)) {
407
+ this.logger.debug(`Execution ${executionId} finished with status ${result?.status ?? 'missing'}`);
408
+ clearInterval(poller);
409
+ resolve();
410
+ }
411
+ }
412
+ catch (error) {
413
+ this.logger.error(`Stopping polling for execution ${executionId} due to error.`);
414
+ clearInterval(poller);
415
+ if (error instanceof Error) {
416
+ this.logger.error(`Error while polling execution ${executionId}: ${error.message}`, {
417
+ error,
418
+ });
419
+ }
420
+ else {
421
+ this.logger.error(`Unknown error while polling execution ${executionId}`, { error });
422
+ }
423
+ if (error instanceof Error) {
424
+ reject(error);
425
+ }
426
+ else {
427
+ reject(new Error('Unknown error while polling execution status'));
428
+ }
429
+ }
430
+ }, chat_hub_constants_1.EXECUTION_POLL_INTERVAL);
431
+ });
432
+ }
433
+ async waitForExecutionPromise(executionId) {
1010
434
  try {
1011
435
  const result = await this.activeExecutions.getPostExecutePromise(executionId);
1012
436
  if (!result) {
@@ -1023,10 +447,10 @@ let ChatHubService = class ChatHubService {
1023
447
  throw error;
1024
448
  }
1025
449
  }
1026
- async executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId = null) {
450
+ async executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, responseMode) {
1027
451
  try {
1028
452
  const executionMode = model.provider === 'n8n' ? 'webhook' : 'chat';
1029
- await this.executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, executionMode);
453
+ await this.executeChatWorkflow(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId, executionMode, responseMode);
1030
454
  }
1031
455
  finally {
1032
456
  if (model.provider !== 'n8n') {
@@ -1034,8 +458,8 @@ let ChatHubService = class ChatHubService {
1034
458
  }
1035
459
  }
1036
460
  }
1037
- async generateSessionTitle(user, sessionId, humanMessage, credentials, model) {
1038
- const { executionData, workflowData } = await this.prepareTitleGenerationWorkflow(user, sessionId, humanMessage, credentials, model);
461
+ async generateSessionTitle(user, sessionId, humanMessage, attachments, credentials, model) {
462
+ const { executionData, workflowData } = await this.prepareTitleGenerationWorkflow(user, sessionId, humanMessage, attachments, credentials, model);
1039
463
  try {
1040
464
  const title = await this.runTitleWorkflowAndGetTitle(user, workflowData, executionData);
1041
465
  if (title) {
@@ -1052,14 +476,14 @@ let ChatHubService = class ChatHubService {
1052
476
  await this.deleteChatWorkflow(workflowData.id);
1053
477
  }
1054
478
  }
1055
- async prepareTitleGenerationWorkflow(user, sessionId, humanMessage, incomingCredentials, incomingModel) {
479
+ async prepareTitleGenerationWorkflow(user, sessionId, humanMessage, attachments, incomingCredentials, incomingModel) {
1056
480
  return await this.messageRepository.manager.transaction(async (trx) => {
1057
481
  const { resolvedCredentials, resolvedModel, credential } = await this.resolveCredentialsAndModelForTitle(user, incomingModel, incomingCredentials, trx);
1058
482
  if (!credential) {
1059
483
  throw new bad_request_error_1.BadRequestError('Could not determine credentials for title generation');
1060
484
  }
1061
- this.logger.debug(`Using credential ID ${credential.id} for title generation in project ${credential.projectId}, model ${JSON.stringify(resolvedModel)}`);
1062
- return await this.chatHubWorkflowService.createTitleGenerationWorkflow(user.id, sessionId, credential.projectId, humanMessage, resolvedCredentials, resolvedModel, trx);
485
+ this.logger.debug(`Using credential ID ${credential.id} for title generation in project ${credential.projectId}, model ${(0, n8n_workflow_1.jsonStringify)(resolvedModel)}`);
486
+ return await this.chatHubWorkflowService.createTitleGenerationWorkflow(user.id, sessionId, credential.projectId, humanMessage, attachments, resolvedCredentials, resolvedModel, trx);
1063
487
  });
1064
488
  }
1065
489
  async resolveCredentialsAndModelForTitle(user, model, credentials, trx) {
@@ -1077,11 +501,11 @@ let ChatHubService = class ChatHubService {
1077
501
  };
1078
502
  }
1079
503
  async resolveFromN8nWorkflow(user, { workflowId }, trx) {
1080
- const workflowEntity = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:read'], { includeTags: false, includeParentFolder: false, em: trx });
1081
- if (!workflowEntity) {
504
+ const workflowEntity = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true, em: trx });
505
+ if (!workflowEntity?.activeVersion) {
1082
506
  throw new bad_request_error_1.BadRequestError('Workflow not found for title generation');
1083
507
  }
1084
- const modelNodes = this.findSupportedLLMNodes(workflowEntity);
508
+ const modelNodes = this.findSupportedLLMNodes(workflowEntity.activeVersion.nodes);
1085
509
  this.logger.debug(`Found ${modelNodes.length} LLM nodes in workflow ${workflowEntity.id} for title generation`);
1086
510
  if (modelNodes.length === 0) {
1087
511
  throw new bad_request_error_1.BadRequestError('No supported Model nodes found in workflow for title generation');
@@ -1111,8 +535,8 @@ let ChatHubService = class ChatHubService {
1111
535
  };
1112
536
  return { resolvedCredentials, resolvedModel, credential };
1113
537
  }
1114
- findSupportedLLMNodes(workflowEntity) {
1115
- return workflowEntity.nodes.reduce((acc, node) => {
538
+ findSupportedLLMNodes(nodes) {
539
+ return nodes.reduce((acc, node) => {
1116
540
  const supportedProvider = Object.entries(chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP).find(([_provider, { name }]) => node.type === name);
1117
541
  if (supportedProvider) {
1118
542
  const [provider] = supportedProvider;
@@ -1126,9 +550,6 @@ let ChatHubService = class ChatHubService {
1126
550
  if (!agent) {
1127
551
  throw new bad_request_error_1.BadRequestError('Agent not found for title generation');
1128
552
  }
1129
- if (agent.provider === 'n8n' || agent.provider === 'custom-agent') {
1130
- throw new bad_request_error_1.BadRequestError('Invalid provider for title generation');
1131
- }
1132
553
  const credentialId = agent.credentialId;
1133
554
  if (!credentialId) {
1134
555
  throw new bad_request_error_1.BadRequestError('Credentials not set for agent');
@@ -1147,24 +568,8 @@ let ChatHubService = class ChatHubService {
1147
568
  return { resolvedCredentials, resolvedModel, credential };
1148
569
  }
1149
570
  async runTitleWorkflowAndGetTitle(user, workflowData, executionData) {
1150
- const started = await this.workflowExecutionService.executeChatWorkflow(workflowData, executionData, user, undefined, false, 'chat');
1151
- const executionId = started.executionId;
1152
- if (!executionId) {
1153
- throw new n8n_workflow_1.OperationalError('There was a problem starting the chat execution.');
1154
- }
1155
- let run;
1156
- try {
1157
- run = await this.activeExecutions.getPostExecutePromise(executionId);
1158
- if (!run) {
1159
- throw new n8n_workflow_1.OperationalError('There was a problem executing the chat workflow.');
1160
- }
1161
- }
1162
- catch (error) {
1163
- if (error instanceof n8n_workflow_1.ManualExecutionCancelledError) {
1164
- return null;
1165
- }
1166
- throw error;
1167
- }
571
+ const { executionId } = await this.workflowExecutionService.executeChatWorkflow(workflowData, executionData, user, undefined, false, 'chat');
572
+ await this.waitForExecutionCompletion(executionId);
1168
573
  const execution = await this.executionRepository.findWithUnflattenedData(executionId, [
1169
574
  workflowData.id,
1170
575
  ]);
@@ -1238,21 +643,7 @@ let ChatHubService = class ChatHubService {
1238
643
  const data = hasMore ? sessions.slice(0, limit) : sessions;
1239
644
  const nextCursor = hasMore ? data[data.length - 1].id : null;
1240
645
  return {
1241
- data: data.map((session) => ({
1242
- id: session.id,
1243
- title: session.title,
1244
- ownerId: session.ownerId,
1245
- lastMessageAt: session.lastMessageAt?.toISOString() ?? null,
1246
- credentialId: session.credentialId,
1247
- provider: session.provider,
1248
- model: session.model,
1249
- workflowId: session.workflowId,
1250
- agentId: session.agentId,
1251
- agentName: session.agentName ?? '',
1252
- createdAt: session.createdAt.toISOString(),
1253
- updatedAt: session.updatedAt.toISOString(),
1254
- tools: session.tools,
1255
- })),
646
+ data: data.map((session) => this.convertSessionEntityToDto(session)),
1256
647
  nextCursor,
1257
648
  hasMore,
1258
649
  };
@@ -1264,21 +655,7 @@ let ChatHubService = class ChatHubService {
1264
655
  }
1265
656
  const messages = await this.messageRepository.getManyBySessionId(sessionId);
1266
657
  return {
1267
- session: {
1268
- id: session.id,
1269
- title: session.title,
1270
- ownerId: session.ownerId,
1271
- lastMessageAt: session.lastMessageAt?.toISOString() ?? null,
1272
- credentialId: session.credentialId,
1273
- provider: session.provider,
1274
- model: session.model,
1275
- workflowId: session.workflowId,
1276
- agentId: session.agentId,
1277
- agentName: session.agentName ?? '',
1278
- createdAt: session.createdAt.toISOString(),
1279
- updatedAt: session.updatedAt.toISOString(),
1280
- tools: session.tools,
1281
- },
658
+ session: this.convertSessionEntityToDto(session),
1282
659
  conversation: {
1283
660
  messages: Object.fromEntries(messages.map((m) => [m.id, this.convertMessageToDto(m)])),
1284
661
  },
@@ -1363,6 +740,8 @@ let ChatHubService = class ChatHubService {
1363
740
  sessionUpdates.title = updates.title;
1364
741
  if (updates.credentialId !== undefined)
1365
742
  sessionUpdates.credentialId = updates.credentialId;
743
+ if (updates.tools !== undefined)
744
+ sessionUpdates.tools = updates.tools;
1366
745
  return await this.sessionRepository.updateChatSession(sessionId, sessionUpdates);
1367
746
  }
1368
747
  async deleteSession(userId, sessionId) {
@@ -1381,16 +760,39 @@ let ChatHubService = class ChatHubService {
1381
760
  }
1382
761
  }
1383
762
  if (model.provider === 'n8n') {
1384
- const workflow = await this.workflowFinderService.findWorkflowForUser(model.workflowId, user, ['workflow:read'], { includeTags: false, includeParentFolder: false });
1385
- if (!workflow) {
763
+ const workflowEntity = await this.workflowFinderService.findWorkflowForUser(model.workflowId, user, ['workflow:execute-chat'], { includeTags: false, includeParentFolder: false, includeActiveVersion: true });
764
+ if (!workflowEntity?.activeVersion) {
1386
765
  throw new bad_request_error_1.BadRequestError('Workflow not found for chat session initialization');
1387
766
  }
1388
- const chatTrigger = workflow.nodes?.find((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
767
+ const chatTrigger = workflowEntity.activeVersion.nodes?.find((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
1389
768
  if (!chatTrigger) {
1390
769
  throw new bad_request_error_1.BadRequestError('Chat trigger not found in workflow for chat session initialization');
1391
770
  }
1392
771
  }
1393
772
  }
773
+ convertSessionEntityToDto(session) {
774
+ const agent = session.workflow
775
+ ? this.chatHubModelsService.extractModelFromWorkflow(session.workflow)
776
+ : session.agent
777
+ ? this.chatHubAgentService.convertAgentEntityToModel(session.agent)
778
+ : undefined;
779
+ return {
780
+ id: session.id,
781
+ title: session.title,
782
+ ownerId: session.ownerId,
783
+ lastMessageAt: session.lastMessageAt?.toISOString() ?? null,
784
+ credentialId: session.credentialId,
785
+ provider: session.provider,
786
+ model: session.model,
787
+ workflowId: session.workflowId,
788
+ agentId: session.agentId,
789
+ agentName: agent?.name ?? session.agentName ?? session.model ?? '',
790
+ agentIcon: agent?.icon ?? null,
791
+ createdAt: session.createdAt.toISOString(),
792
+ updatedAt: session.updatedAt.toISOString(),
793
+ tools: session.tools,
794
+ };
795
+ }
1394
796
  };
1395
797
  exports.ChatHubService = ChatHubService;
1396
798
  exports.ChatHubService = ChatHubService = __decorate([
@@ -1398,20 +800,20 @@ exports.ChatHubService = ChatHubService = __decorate([
1398
800
  __metadata("design:paramtypes", [backend_common_1.Logger,
1399
801
  n8n_core_1.ErrorReporter,
1400
802
  execution_service_1.ExecutionService,
1401
- dynamic_node_parameters_service_1.DynamicNodeParametersService,
1402
803
  db_1.ExecutionRepository,
1403
804
  workflow_execution_service_1.WorkflowExecutionService,
1404
- workflow_service_1.WorkflowService,
1405
805
  workflow_finder_service_1.WorkflowFinderService,
1406
806
  db_1.WorkflowRepository,
1407
807
  active_executions_1.ActiveExecutions,
1408
808
  chat_session_repository_1.ChatHubSessionRepository,
1409
809
  chat_message_repository_1.ChatHubMessageRepository,
1410
- credentials_finder_service_1.CredentialsFinderService,
1411
810
  chat_hub_agent_service_1.ChatHubAgentService,
1412
811
  chat_hub_credentials_service_1.ChatHubCredentialsService,
1413
812
  chat_hub_workflow_service_1.ChatHubWorkflowService,
813
+ chat_hub_models_service_1.ChatHubModelsService,
1414
814
  chat_hub_settings_service_1.ChatHubSettingsService,
1415
- chat_hub_attachment_service_1.ChatHubAttachmentService])
815
+ chat_hub_attachment_service_1.ChatHubAttachmentService,
816
+ n8n_core_1.InstanceSettings,
817
+ config_1.GlobalConfig])
1416
818
  ], ChatHubService);
1417
819
  //# sourceMappingURL=chat-hub.service.js.map