n8n 2.32.5 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (711) hide show
  1. package/dist/active-workflow-manager.d.ts +4 -1
  2. package/dist/active-workflow-manager.js +18 -16
  3. package/dist/active-workflow-manager.js.map +1 -1
  4. package/dist/build.tsbuildinfo +1 -1
  5. package/dist/collaboration/collaboration.service.d.ts +1 -0
  6. package/dist/collaboration/collaboration.service.js +12 -1
  7. package/dist/collaboration/collaboration.service.js.map +1 -1
  8. package/dist/commands/base-command.d.ts +3 -2
  9. package/dist/commands/base-command.js +31 -23
  10. package/dist/commands/base-command.js.map +1 -1
  11. package/dist/commands/db/revert.js.map +1 -1
  12. package/dist/commands/import/credentials.d.ts +1 -1
  13. package/dist/commands/import/credentials.js +91 -25
  14. package/dist/commands/import/credentials.js.map +1 -1
  15. package/dist/commands/ldap/reset.js.map +1 -1
  16. package/dist/commands/start.d.ts +1 -0
  17. package/dist/commands/start.js +3 -1
  18. package/dist/commands/start.js.map +1 -1
  19. package/dist/commands/user-management/reset.js +1 -5
  20. package/dist/commands/user-management/reset.js.map +1 -1
  21. package/dist/commands/webhook.d.ts +1 -0
  22. package/dist/commands/webhook.js +1 -1
  23. package/dist/commands/webhook.js.map +1 -1
  24. package/dist/commands/worker.d.ts +1 -0
  25. package/dist/commands/worker.js +1 -1
  26. package/dist/commands/worker.js.map +1 -1
  27. package/dist/constants.js +19 -0
  28. package/dist/constants.js.map +1 -1
  29. package/dist/controllers/ai.controller.d.ts +4 -5
  30. package/dist/controllers/ai.controller.js +5 -22
  31. package/dist/controllers/ai.controller.js.map +1 -1
  32. package/dist/controllers/e2e.controller.d.ts +15 -2
  33. package/dist/controllers/e2e.controller.js +25 -2
  34. package/dist/controllers/e2e.controller.js.map +1 -1
  35. package/dist/controllers/oauth/oauth2-credential.controller.js +5 -1
  36. package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
  37. package/dist/controllers/project.controller.js.map +1 -1
  38. package/dist/controllers/role.controller.d.ts +2 -2
  39. package/dist/controllers/role.controller.js +4 -3
  40. package/dist/controllers/role.controller.js.map +1 -1
  41. package/dist/controllers/users.controller.d.ts +5 -0
  42. package/dist/controllers/users.controller.js +1 -0
  43. package/dist/controllers/users.controller.js.map +1 -1
  44. package/dist/credentials/credential-connection-status-proxy.js.map +1 -1
  45. package/dist/credentials/credential-dependency.service.js.map +1 -1
  46. package/dist/credentials/credentials-finder.service.d.ts +7 -2
  47. package/dist/credentials/credentials-finder.service.js +33 -8
  48. package/dist/credentials/credentials-finder.service.js.map +1 -1
  49. package/dist/credentials/credentials.controller.d.ts +6 -0
  50. package/dist/credentials/credentials.controller.js +44 -5
  51. package/dist/credentials/credentials.controller.js.map +1 -1
  52. package/dist/credentials/credentials.service.d.ts +38 -5
  53. package/dist/credentials/credentials.service.ee.d.ts +4 -2
  54. package/dist/credentials/credentials.service.ee.js +8 -7
  55. package/dist/credentials/credentials.service.ee.js.map +1 -1
  56. package/dist/credentials/credentials.service.js +227 -21
  57. package/dist/credentials/credentials.service.js.map +1 -1
  58. package/dist/credentials/instance-credential-broker.d.ts +24 -0
  59. package/dist/credentials/instance-credential-broker.js +80 -0
  60. package/dist/credentials/instance-credential-broker.js.map +1 -0
  61. package/dist/credentials/instance-credential-use.registry.d.ts +14 -0
  62. package/dist/credentials/instance-credential-use.registry.js +43 -0
  63. package/dist/credentials/instance-credential-use.registry.js.map +1 -0
  64. package/dist/credentials-helper.js +4 -0
  65. package/dist/credentials-helper.js.map +1 -1
  66. package/dist/credentials-overwrites.js +2 -1
  67. package/dist/credentials-overwrites.js.map +1 -1
  68. package/dist/errors/response-errors/workflow-deactivation-bad-request.error.d.ts +9 -0
  69. package/dist/errors/response-errors/workflow-deactivation-bad-request.error.js +13 -0
  70. package/dist/errors/response-errors/workflow-deactivation-bad-request.error.js.map +1 -0
  71. package/dist/evaluation.ee/evaluation-collection.service.d.ts +12 -2
  72. package/dist/evaluation.ee/evaluation-collection.service.js +132 -20
  73. package/dist/evaluation.ee/evaluation-collection.service.js.map +1 -1
  74. package/dist/evaluation.ee/evaluation-collections.controller.ee.d.ts +12 -0
  75. package/dist/evaluation.ee/evaluation-collections.controller.ee.js +12 -0
  76. package/dist/evaluation.ee/evaluation-collections.controller.ee.js.map +1 -1
  77. package/dist/evaluation.ee/insights/eval-insights.service.d.ts +11 -4
  78. package/dist/evaluation.ee/insights/eval-insights.service.js +136 -30
  79. package/dist/evaluation.ee/insights/eval-insights.service.js.map +1 -1
  80. package/dist/evaluation.ee/insights/insights-context-builder.d.ts +59 -0
  81. package/dist/evaluation.ee/insights/insights-context-builder.js +179 -0
  82. package/dist/evaluation.ee/insights/insights-context-builder.js.map +1 -0
  83. package/dist/evaluation.ee/insights/insights-model-resolver.d.ts +16 -0
  84. package/dist/evaluation.ee/insights/insights-model-resolver.js +65 -0
  85. package/dist/evaluation.ee/insights/insights-model-resolver.js.map +1 -0
  86. package/dist/evaluation.ee/metric-scales.d.ts +4 -0
  87. package/dist/evaluation.ee/metric-scales.js +13 -0
  88. package/dist/evaluation.ee/metric-scales.js.map +1 -0
  89. package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +5 -0
  90. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +40 -4
  91. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
  92. package/dist/evaluation.ee/test-runner/workflow-compiler.service.d.ts +6 -1
  93. package/dist/evaluation.ee/test-runner/workflow-compiler.service.js +53 -4
  94. package/dist/evaluation.ee/test-runner/workflow-compiler.service.js.map +1 -1
  95. package/dist/evaluation.ee/test-runs.controller.ee.d.ts +4 -2
  96. package/dist/evaluation.ee/test-runs.controller.ee.js +26 -6
  97. package/dist/evaluation.ee/test-runs.controller.ee.js.map +1 -1
  98. package/dist/eventbus/message-event-bus/message-event-bus.js.map +1 -1
  99. package/dist/events/maps/workflow-publication-metrics.event-map.d.ts +2 -0
  100. package/dist/events/relays/telemetry.event-relay.js +5 -0
  101. package/dist/events/relays/telemetry.event-relay.js.map +1 -1
  102. package/dist/executions/execution-data/execution-data-json-store.d.ts +6 -4
  103. package/dist/executions/execution-data/execution-data-json-store.js +17 -5
  104. package/dist/executions/execution-data/execution-data-json-store.js.map +1 -1
  105. package/dist/executions/pre-execution-checks/credentials-permission-checker.d.ts +1 -0
  106. package/dist/executions/pre-execution-checks/credentials-permission-checker.js +17 -5
  107. package/dist/executions/pre-execution-checks/credentials-permission-checker.js.map +1 -1
  108. package/dist/external-hooks.d.ts +18 -9
  109. package/dist/external-hooks.js +13 -0
  110. package/dist/external-hooks.js.map +1 -1
  111. package/dist/license.d.ts +2 -0
  112. package/dist/license.js +13 -1
  113. package/dist/license.js.map +1 -1
  114. package/dist/metrics/prometheus/workflow-info-metrics.service.d.ts +4 -1
  115. package/dist/metrics/prometheus/workflow-info-metrics.service.js +27 -8
  116. package/dist/metrics/prometheus/workflow-info-metrics.service.js.map +1 -1
  117. package/dist/metrics/prometheus/workflow-publication-metrics.service.js +11 -1
  118. package/dist/metrics/prometheus/workflow-publication-metrics.service.js.map +1 -1
  119. package/dist/modules/agents/agent-chat.controller.js +10 -2
  120. package/dist/modules/agents/agent-chat.controller.js.map +1 -1
  121. package/dist/modules/agents/agent-config.service.js +1 -1
  122. package/dist/modules/agents/agent-config.service.js.map +1 -1
  123. package/dist/modules/agents/agent-execution-orchestrator.service.d.ts +7 -1
  124. package/dist/modules/agents/agent-execution-orchestrator.service.js +84 -43
  125. package/dist/modules/agents/agent-execution-orchestrator.service.js.map +1 -1
  126. package/dist/modules/agents/agent-execution.service.d.ts +12 -1
  127. package/dist/modules/agents/agent-execution.service.js +82 -7
  128. package/dist/modules/agents/agent-execution.service.js.map +1 -1
  129. package/dist/modules/agents/agent-integration-persistence.service.js +2 -2
  130. package/dist/modules/agents/agent-integration-persistence.service.js.map +1 -1
  131. package/dist/modules/agents/agent-integrations.controller.js +4 -2
  132. package/dist/modules/agents/agent-integrations.controller.js.map +1 -1
  133. package/dist/modules/agents/agent-knowledge-sandbox.service.js +5 -3
  134. package/dist/modules/agents/agent-knowledge-sandbox.service.js.map +1 -1
  135. package/dist/modules/agents/agent-knowledge.service.d.ts +0 -1
  136. package/dist/modules/agents/agent-knowledge.service.js +2 -9
  137. package/dist/modules/agents/agent-knowledge.service.js.map +1 -1
  138. package/dist/modules/agents/agent-model-catalog.service.js +1 -1
  139. package/dist/modules/agents/agent-model-catalog.service.js.map +1 -1
  140. package/dist/modules/agents/agent-publish.controller.js +2 -2
  141. package/dist/modules/agents/agent-publish.controller.js.map +1 -1
  142. package/dist/modules/agents/agent-publish.service.d.ts +7 -3
  143. package/dist/modules/agents/agent-publish.service.js +31 -8
  144. package/dist/modules/agents/agent-publish.service.js.map +1 -1
  145. package/dist/modules/agents/agent-run-tracing.service.d.ts +30 -0
  146. package/dist/modules/agents/agent-run-tracing.service.js +63 -0
  147. package/dist/modules/agents/agent-run-tracing.service.js.map +1 -0
  148. package/dist/modules/agents/agent-runtime-instrumentation.d.ts +26 -0
  149. package/dist/{blob-storage/types.js → modules/agents/agent-runtime-instrumentation.js} +1 -1
  150. package/dist/modules/agents/agent-runtime-instrumentation.js.map +1 -0
  151. package/dist/modules/agents/agent-runtime-reconstruction.service.d.ts +3 -1
  152. package/dist/modules/agents/agent-runtime-reconstruction.service.js +31 -8
  153. package/dist/modules/agents/agent-runtime-reconstruction.service.js.map +1 -1
  154. package/dist/modules/agents/agent-sse-stream.js +31 -6
  155. package/dist/modules/agents/agent-sse-stream.js.map +1 -1
  156. package/dist/modules/agents/agent-validation.service.d.ts +2 -1
  157. package/dist/modules/agents/agent-validation.service.js +21 -6
  158. package/dist/modules/agents/agent-validation.service.js.map +1 -1
  159. package/dist/modules/agents/agent-workflow-execution.service.d.ts +5 -3
  160. package/dist/modules/agents/agent-workflow-execution.service.js +31 -9
  161. package/dist/modules/agents/agent-workflow-execution.service.js.map +1 -1
  162. package/dist/modules/agents/agents-tools.service.js +12 -0
  163. package/dist/modules/agents/agents-tools.service.js.map +1 -1
  164. package/dist/modules/agents/agents.module.js +13 -0
  165. package/dist/modules/agents/agents.module.js.map +1 -1
  166. package/dist/modules/agents/agents.service.d.ts +3 -1
  167. package/dist/modules/agents/agents.service.js +5 -2
  168. package/dist/modules/agents/agents.service.js.map +1 -1
  169. package/dist/modules/agents/builder/agents-builder-model-recommendations.js +6 -4
  170. package/dist/modules/agents/builder/agents-builder-model-recommendations.js.map +1 -1
  171. package/dist/modules/agents/builder/agents-builder-prompts.d.ts +5 -4
  172. package/dist/modules/agents/builder/agents-builder-prompts.js +109 -34
  173. package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
  174. package/dist/modules/agents/builder/agents-builder-tools.service.d.ts +16 -2
  175. package/dist/modules/agents/builder/agents-builder-tools.service.js +201 -39
  176. package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
  177. package/dist/modules/agents/builder/agents-builder.service.js +7 -2
  178. package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
  179. package/dist/modules/agents/builder/builder-config-telemetry.d.ts +12 -0
  180. package/dist/modules/agents/builder/builder-config-telemetry.js +67 -0
  181. package/dist/modules/agents/builder/builder-config-telemetry.js.map +1 -0
  182. package/dist/modules/agents/builder/builder-tool-names.d.ts +2 -0
  183. package/dist/modules/agents/builder/builder-tool-names.js +2 -0
  184. package/dist/modules/agents/builder/builder-tool-names.js.map +1 -1
  185. package/dist/modules/agents/builder/interactive/ask-credential.tool.d.ts +3 -0
  186. package/dist/modules/agents/builder/interactive/ask-credential.tool.js +35 -7
  187. package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
  188. package/dist/modules/agents/builder/interactive/ask-questions.tool.d.ts +4 -1
  189. package/dist/modules/agents/builder/interactive/ask-questions.tool.js +13 -1
  190. package/dist/modules/agents/builder/interactive/ask-questions.tool.js.map +1 -1
  191. package/dist/modules/agents/builder/interactive/configure-channel.tool.d.ts +2 -0
  192. package/dist/modules/agents/builder/interactive/configure-channel.tool.js +7 -1
  193. package/dist/modules/agents/builder/interactive/configure-channel.tool.js.map +1 -1
  194. package/dist/modules/agents/builder/interactive/finish-setup.tool.d.ts +17 -0
  195. package/dist/modules/agents/builder/interactive/finish-setup.tool.js +316 -0
  196. package/dist/modules/agents/builder/interactive/finish-setup.tool.js.map +1 -0
  197. package/dist/modules/agents/builder/interactive/index.d.ts +1 -0
  198. package/dist/modules/agents/builder/interactive/index.js +3 -1
  199. package/dist/modules/agents/builder/interactive/index.js.map +1 -1
  200. package/dist/modules/agents/builder/interactive/resolve-llm.tool.d.ts +8 -0
  201. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +87 -6
  202. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -1
  203. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +6 -5
  204. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -1
  205. package/dist/modules/agents/builder/prompts/config-rules.prompt.js +6 -5
  206. package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -1
  207. package/dist/modules/agents/builder/prompts/initial-build.prompt.d.ts +2 -0
  208. package/dist/modules/agents/builder/prompts/initial-build.prompt.js +56 -0
  209. package/dist/modules/agents/builder/prompts/initial-build.prompt.js.map +1 -0
  210. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +6 -3
  211. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js.map +1 -1
  212. package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -1
  213. package/dist/modules/agents/builder/prompts/memory.prompt.js +2 -2
  214. package/dist/modules/agents/builder/prompts/memory.prompt.js.map +1 -1
  215. package/dist/modules/agents/builder/prompts/planner-todos.prompt.d.ts +2 -0
  216. package/dist/modules/agents/builder/prompts/planner-todos.prompt.js +22 -0
  217. package/dist/modules/agents/builder/prompts/planner-todos.prompt.js.map +1 -0
  218. package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -1
  219. package/dist/modules/agents/builder/prompts/tools.prompt.js +12 -12
  220. package/dist/modules/agents/builder/resolve-integration.tool.js +1 -1
  221. package/dist/modules/agents/builder/resolve-integration.tool.js.map +1 -1
  222. package/dist/modules/agents/builder/skills/external-services.skill.d.ts +2 -0
  223. package/dist/modules/agents/builder/skills/external-services.skill.js +361 -0
  224. package/dist/modules/agents/builder/skills/external-services.skill.js.map +1 -0
  225. package/dist/modules/agents/builder/skills/index.js +2 -6
  226. package/dist/modules/agents/builder/skills/index.js.map +1 -1
  227. package/dist/modules/agents/builder/skills/memory.skill.js +2 -1
  228. package/dist/modules/agents/builder/skills/memory.skill.js.map +1 -1
  229. package/dist/modules/agents/builder/skills/resource-locators.skill.js +17 -3
  230. package/dist/modules/agents/builder/skills/resource-locators.skill.js.map +1 -1
  231. package/dist/modules/agents/builder/skills/target-skills.skill.js +12 -9
  232. package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -1
  233. package/dist/modules/agents/builder/skills/target-tasks.skill.js +14 -10
  234. package/dist/modules/agents/builder/skills/target-tasks.skill.js.map +1 -1
  235. package/dist/modules/agents/builder/verify-mcp-server.tool.d.ts +4 -0
  236. package/dist/modules/agents/builder/verify-mcp-server.tool.js +30 -5
  237. package/dist/modules/agents/builder/verify-mcp-server.tool.js.map +1 -1
  238. package/dist/modules/agents/entities/agent-execution.entity.d.ts +2 -1
  239. package/dist/modules/agents/entities/agent-execution.entity.js +4 -0
  240. package/dist/modules/agents/entities/agent-execution.entity.js.map +1 -1
  241. package/dist/modules/agents/execution-log/agent-execution-log-store.d.ts +17 -0
  242. package/dist/modules/agents/execution-log/agent-execution-log-store.js +58 -0
  243. package/dist/modules/agents/execution-log/agent-execution-log-store.js.map +1 -0
  244. package/dist/modules/agents/execution-log/agent-execution-log-write.error.d.ts +5 -0
  245. package/dist/modules/agents/execution-log/agent-execution-log-write.error.js +11 -0
  246. package/dist/modules/agents/execution-log/agent-execution-log-write.error.js.map +1 -0
  247. package/dist/modules/agents/execution-log/corrupted-agent-execution-log.error.d.ts +5 -0
  248. package/dist/modules/agents/execution-log/corrupted-agent-execution-log.error.js +11 -0
  249. package/dist/modules/agents/execution-log/corrupted-agent-execution-log.error.js.map +1 -0
  250. package/dist/modules/agents/instance-ai-builder-delegate.adapter.d.ts +1 -1
  251. package/dist/modules/agents/instance-ai-builder-delegate.adapter.js +4 -2
  252. package/dist/modules/agents/instance-ai-builder-delegate.adapter.js.map +1 -1
  253. package/dist/modules/agents/integrations/agent-chat-bridge.js +8 -4
  254. package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
  255. package/dist/modules/agents/integrations/agent-chat-stream-consumer.d.ts +4 -2
  256. package/dist/modules/agents/integrations/agent-chat-stream-consumer.js +62 -6
  257. package/dist/modules/agents/integrations/agent-chat-stream-consumer.js.map +1 -1
  258. package/dist/modules/agents/integrations/integration-tool-factory.d.ts +7 -7
  259. package/dist/modules/agents/integrations/integration-tool-factory.js +13 -10
  260. package/dist/modules/agents/integrations/integration-tool-factory.js.map +1 -1
  261. package/dist/modules/agents/integrations/integration-tool-schema.d.ts +7 -7
  262. package/dist/modules/agents/integrations/integration-tool-schema.js +7 -7
  263. package/dist/modules/agents/integrations/integration-tool-schema.js.map +1 -1
  264. package/dist/modules/agents/integrations/slack-app-setup.service.js +2 -1
  265. package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -1
  266. package/dist/modules/agents/json-config/from-json-config.d.ts +21 -0
  267. package/dist/modules/agents/json-config/from-json-config.js +16 -4
  268. package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
  269. package/dist/modules/agents/json-config/mcp-client-factory.d.ts +4 -0
  270. package/dist/modules/agents/json-config/mcp-client-factory.js +6 -1
  271. package/dist/modules/agents/json-config/mcp-client-factory.js.map +1 -1
  272. package/dist/modules/agents/json-config/sanitize-unknown-agent-credentials.js +14 -1
  273. package/dist/modules/agents/json-config/sanitize-unknown-agent-credentials.js.map +1 -1
  274. package/dist/modules/agents/{builder/interactive/llm-provider-defaults.d.ts → llm-provider-defaults.d.ts} +1 -0
  275. package/dist/modules/agents/{builder/interactive/llm-provider-defaults.js → llm-provider-defaults.js} +14 -1
  276. package/dist/modules/agents/llm-provider-defaults.js.map +1 -0
  277. package/dist/modules/agents/repositories/agent-execution.repository.d.ts +4 -0
  278. package/dist/modules/agents/repositories/agent-execution.repository.js +31 -0
  279. package/dist/modules/agents/repositories/agent-execution.repository.js.map +1 -1
  280. package/dist/modules/agents/sub-agents/delegate-sub-agent-tool.js +1 -0
  281. package/dist/modules/agents/sub-agents/delegate-sub-agent-tool.js.map +1 -1
  282. package/dist/modules/agents/sub-agents/sub-agent-foreground-runner.d.ts +4 -1
  283. package/dist/modules/agents/sub-agents/sub-agent-foreground-runner.js +7 -1
  284. package/dist/modules/agents/sub-agents/sub-agent-foreground-runner.js.map +1 -1
  285. package/dist/modules/agents/tools/node-tool-factory.d.ts +2 -0
  286. package/dist/modules/agents/tools/node-tool-factory.js +8 -0
  287. package/dist/modules/agents/tools/node-tool-factory.js.map +1 -1
  288. package/dist/modules/agents/tools/workflow-tool-factory.d.ts +3 -1
  289. package/dist/modules/agents/tools/workflow-tool-factory.js +9 -3
  290. package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -1
  291. package/dist/modules/agents/utils/execution-to-message-mapper.js +4 -2
  292. package/dist/modules/agents/utils/execution-to-message-mapper.js.map +1 -1
  293. package/dist/modules/agents/utils/node-tool-validation.js +6 -0
  294. package/dist/modules/agents/utils/node-tool-validation.js.map +1 -1
  295. package/dist/modules/breaking-changes/rules/index.d.ts +3 -0
  296. package/dist/modules/breaking-changes/rules/index.js +3 -0
  297. package/dist/modules/breaking-changes/rules/index.js.map +1 -1
  298. package/dist/modules/breaking-changes/rules/v3/chat-trigger-embedded-json.rule.d.ts +10 -0
  299. package/dist/modules/breaking-changes/rules/v3/chat-trigger-embedded-json.rule.js +58 -0
  300. package/dist/modules/breaking-changes/rules/v3/chat-trigger-embedded-json.rule.js.map +1 -0
  301. package/dist/modules/breaking-changes/rules/v3/removed-nodes-with-replacements.rule.d.ts +239 -0
  302. package/dist/modules/breaking-changes/rules/v3/removed-nodes-with-replacements.rule.js +445 -0
  303. package/dist/modules/breaking-changes/rules/v3/removed-nodes-with-replacements.rule.js.map +1 -0
  304. package/dist/modules/breaking-changes/rules/v3/removed-nodes.rule.d.ts +11 -0
  305. package/dist/modules/breaking-changes/rules/v3/removed-nodes.rule.js +61 -0
  306. package/dist/modules/breaking-changes/rules/v3/removed-nodes.rule.js.map +1 -0
  307. package/dist/modules/community-packages/installed-nodes.entity.js +1 -1
  308. package/dist/modules/community-packages/installed-nodes.entity.js.map +1 -1
  309. package/dist/modules/data-table/data-table-proxy.service.js +13 -0
  310. package/dist/modules/data-table/data-table-proxy.service.js.map +1 -1
  311. package/dist/modules/data-table/data-table.controller.js +1 -1
  312. package/dist/modules/data-table/data-table.controller.js.map +1 -1
  313. package/dist/modules/data-table/data-table.service.d.ts +1 -1
  314. package/dist/modules/data-table/data-table.service.js.map +1 -1
  315. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-user-entry.repository.js.map +1 -1
  316. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -1
  317. package/dist/modules/instance-ai/eval/agent-execution.service.d.ts +26 -0
  318. package/dist/modules/instance-ai/eval/agent-execution.service.js +508 -0
  319. package/dist/modules/instance-ai/eval/agent-execution.service.js.map +1 -0
  320. package/dist/modules/instance-ai/eval/agent-model-turn-recorder.d.ts +9 -0
  321. package/dist/modules/instance-ai/eval/agent-model-turn-recorder.js +110 -0
  322. package/dist/modules/instance-ai/eval/agent-model-turn-recorder.js.map +1 -0
  323. package/dist/modules/instance-ai/eval/agent-scenario-seed.d.ts +14 -0
  324. package/dist/modules/instance-ai/eval/agent-scenario-seed.js +98 -0
  325. package/dist/modules/instance-ai/eval/agent-scenario-seed.js.map +1 -0
  326. package/dist/modules/instance-ai/eval/execution.service.js +3 -3
  327. package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
  328. package/dist/modules/instance-ai/eval/mcp-mock-fetch.d.ts +28 -0
  329. package/dist/modules/instance-ai/eval/mcp-mock-fetch.js +265 -0
  330. package/dist/modules/instance-ai/eval/mcp-mock-fetch.js.map +1 -0
  331. package/dist/modules/instance-ai/eval/mock-utils.d.ts +4 -0
  332. package/dist/modules/instance-ai/eval/mock-utils.js +41 -0
  333. package/dist/modules/instance-ai/eval/mock-utils.js.map +1 -0
  334. package/dist/modules/instance-ai/eval/request-sanitizer.d.ts +1 -0
  335. package/dist/modules/instance-ai/eval/request-sanitizer.js +26 -0
  336. package/dist/modules/instance-ai/eval/request-sanitizer.js.map +1 -1
  337. package/dist/modules/instance-ai/eval/web-search-mock.d.ts +26 -0
  338. package/dist/modules/instance-ai/eval/web-search-mock.js +122 -0
  339. package/dist/modules/instance-ai/eval/web-search-mock.js.map +1 -0
  340. package/dist/modules/instance-ai/event-bus/interrupted-run-sweeper.d.ts +8 -0
  341. package/dist/modules/instance-ai/event-bus/interrupted-run-sweeper.js +85 -11
  342. package/dist/modules/instance-ai/event-bus/interrupted-run-sweeper.js.map +1 -1
  343. package/dist/modules/instance-ai/instance-ai-error-reporter.service.js +13 -0
  344. package/dist/modules/instance-ai/instance-ai-error-reporter.service.js.map +1 -1
  345. package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +3 -3
  346. package/dist/modules/instance-ai/instance-ai-memory.service.js +5 -11
  347. package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
  348. package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +42 -14
  349. package/dist/modules/instance-ai/instance-ai-settings.service.js +650 -174
  350. package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
  351. package/dist/modules/instance-ai/instance-ai-test.controller.js +4 -1
  352. package/dist/modules/instance-ai/instance-ai-test.controller.js.map +1 -1
  353. package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +2 -1
  354. package/dist/modules/instance-ai/instance-ai.adapter.service.js +26 -2
  355. package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
  356. package/dist/modules/instance-ai/instance-ai.controller.d.ts +14 -6
  357. package/dist/modules/instance-ai/instance-ai.controller.js +84 -29
  358. package/dist/modules/instance-ai/instance-ai.controller.js.map +1 -1
  359. package/dist/modules/instance-ai/instance-ai.module.js +9 -2
  360. package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
  361. package/dist/modules/instance-ai/instance-ai.service.d.ts +10 -1
  362. package/dist/modules/instance-ai/instance-ai.service.js +146 -45
  363. package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
  364. package/dist/modules/instance-ai/repositories/instance-ai-event-log.repository.d.ts +1 -1
  365. package/dist/modules/instance-ai/repositories/instance-ai-event-log.repository.js +6 -5
  366. package/dist/modules/instance-ai/repositories/instance-ai-event-log.repository.js.map +1 -1
  367. package/dist/modules/instance-ai/sandbox/instance-ai-sandbox.service.d.ts +6 -2
  368. package/dist/modules/instance-ai/sandbox/instance-ai-sandbox.service.js +55 -14
  369. package/dist/modules/instance-ai/sandbox/instance-ai-sandbox.service.js.map +1 -1
  370. package/dist/modules/mcp/mcp-protected-resource.d.ts +1 -0
  371. package/dist/modules/mcp/mcp-protected-resource.js +4 -0
  372. package/dist/modules/mcp/mcp-protected-resource.js.map +1 -1
  373. package/dist/modules/mcp/mcp-server-middleware.service.js +2 -1
  374. package/dist/modules/mcp/mcp-server-middleware.service.js.map +1 -1
  375. package/dist/modules/mcp/mcp.controller.d.ts +3 -1
  376. package/dist/modules/mcp/mcp.controller.js +15 -11
  377. package/dist/modules/mcp/mcp.controller.js.map +1 -1
  378. package/dist/modules/mcp/mcp.service.d.ts +7 -2
  379. package/dist/modules/mcp/mcp.service.js +63 -43
  380. package/dist/modules/mcp/mcp.service.js.map +1 -1
  381. package/dist/modules/mcp/mcp.types.d.ts +1 -0
  382. package/dist/modules/mcp/tools/execution-utils.d.ts +3 -1
  383. package/dist/modules/mcp/tools/execution-utils.js +6 -4
  384. package/dist/modules/mcp/tools/execution-utils.js.map +1 -1
  385. package/dist/modules/mcp/tools/get-workflow-details.tool.d.ts +3 -2
  386. package/dist/modules/mcp/tools/get-workflow-details.tool.js +6 -6
  387. package/dist/modules/mcp/tools/get-workflow-details.tool.js.map +1 -1
  388. package/dist/modules/mcp/tools/get-workflow-version.tool.d.ts +3 -2
  389. package/dist/modules/mcp/tools/get-workflow-version.tool.js +1 -1
  390. package/dist/modules/mcp/tools/get-workflow-version.tool.js.map +1 -1
  391. package/dist/modules/mcp/tools/schemas.d.ts +34 -32
  392. package/dist/modules/mcp/tools/schemas.js +14 -2
  393. package/dist/modules/mcp/tools/schemas.js.map +1 -1
  394. package/dist/modules/mcp/tools/test-workflow.tool.d.ts +4 -1
  395. package/dist/modules/mcp/tools/test-workflow.tool.js +13 -5
  396. package/dist/modules/mcp/tools/test-workflow.tool.js.map +1 -1
  397. package/dist/modules/mcp/tools/webhook-utils.d.ts +3 -3
  398. package/dist/modules/mcp/tools/webhook-utils.js +17 -6
  399. package/dist/modules/mcp/tools/webhook-utils.js.map +1 -1
  400. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.d.ts +4 -1
  401. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +5 -1
  402. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
  403. package/dist/modules/mcp/tools/workflow-builder/get-workflow-best-practices.tool.d.ts +3 -1
  404. package/dist/modules/mcp/tools/workflow-builder/get-workflow-best-practices.tool.js +16 -3
  405. package/dist/modules/mcp/tools/workflow-builder/get-workflow-best-practices.tool.js.map +1 -1
  406. package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.d.ts +5 -2
  407. package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js +17 -10
  408. package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js.map +1 -1
  409. package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.d.ts +6 -1
  410. package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js +8 -2
  411. package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js.map +1 -1
  412. package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.d.ts +4 -2
  413. package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.js +8 -1
  414. package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.js.map +1 -1
  415. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +280 -2
  416. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +54 -17
  417. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
  418. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.d.ts +4 -1
  419. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +58 -1
  420. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
  421. package/dist/modules/mcp/tools/workflow-builder/workflow-operations.d.ts +51 -5
  422. package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js +414 -233
  423. package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js.map +1 -1
  424. package/dist/modules/mcp-registry/mcp-registry-test.controller.js +2 -2
  425. package/dist/modules/mcp-registry/mcp-registry-test.controller.js.map +1 -1
  426. package/dist/modules/mcp-registry/mcp-registry.module.js +1 -1
  427. package/dist/modules/mcp-registry/mcp-registry.module.js.map +1 -1
  428. package/dist/modules/n8n-packages/engine/import-orchestrator.d.ts +11 -1
  429. package/dist/modules/n8n-packages/engine/import-orchestrator.js +36 -7
  430. package/dist/modules/n8n-packages/engine/import-orchestrator.js.map +1 -1
  431. package/dist/modules/n8n-packages/engine/import-result.d.ts +3 -2
  432. package/dist/modules/n8n-packages/engine/import-result.js +2 -1
  433. package/dist/modules/n8n-packages/engine/import-result.js.map +1 -1
  434. package/dist/modules/n8n-packages/engine/import-telemetry.d.ts +2 -0
  435. package/dist/modules/n8n-packages/engine/import-telemetry.js +11 -0
  436. package/dist/modules/n8n-packages/engine/import-telemetry.js.map +1 -1
  437. package/dist/modules/n8n-packages/engine/project-package-importer.js +11 -0
  438. package/dist/modules/n8n-packages/engine/project-package-importer.js.map +1 -1
  439. package/dist/modules/n8n-packages/engine/workflow-package-importer.js +10 -1
  440. package/dist/modules/n8n-packages/engine/workflow-package-importer.js.map +1 -1
  441. package/dist/modules/n8n-packages/entities/requirements.types.d.ts +2 -0
  442. package/dist/modules/n8n-packages/entities/requirements.types.js +1 -0
  443. package/dist/modules/n8n-packages/entities/requirements.types.js.map +1 -1
  444. package/dist/modules/n8n-packages/entities/variable/variable-importer.d.ts +9 -0
  445. package/dist/modules/n8n-packages/entities/variable/variable-importer.js +55 -0
  446. package/dist/modules/n8n-packages/entities/variable/variable-importer.js.map +1 -0
  447. package/dist/modules/n8n-packages/entities/variable/variable-missing-mode.d.ts +3 -0
  448. package/dist/modules/n8n-packages/entities/variable/variable-missing-mode.js +12 -0
  449. package/dist/modules/n8n-packages/entities/variable/variable-missing-mode.js.map +1 -0
  450. package/dist/modules/n8n-packages/entities/variable/variable.types.d.ts +14 -0
  451. package/dist/modules/n8n-packages/entities/variable/variable.types.js +7 -0
  452. package/dist/modules/n8n-packages/entities/variable/variable.types.js.map +1 -1
  453. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow-resolver.d.ts +37 -0
  454. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow-resolver.js +165 -0
  455. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow-resolver.js.map +1 -0
  456. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow.exporter.d.ts +39 -0
  457. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow.exporter.js +198 -0
  458. package/dist/modules/n8n-packages/entities/workflow/auto-included-workflow.exporter.js.map +1 -0
  459. package/dist/modules/n8n-packages/entities/workflow/missing-node-type-mode.d.ts +7 -0
  460. package/dist/modules/n8n-packages/entities/workflow/missing-node-type-mode.js +30 -0
  461. package/dist/modules/n8n-packages/entities/workflow/missing-node-type-mode.js.map +1 -0
  462. package/dist/modules/n8n-packages/entities/workflow/node-type-usage.d.ts +11 -0
  463. package/dist/modules/n8n-packages/entities/workflow/node-type-usage.js +27 -0
  464. package/dist/modules/n8n-packages/entities/workflow/node-type-usage.js.map +1 -0
  465. package/dist/modules/n8n-packages/entities/workflow/static-sub-workflow-id.d.ts +2 -0
  466. package/dist/modules/n8n-packages/entities/workflow/static-sub-workflow-id.js +23 -0
  467. package/dist/modules/n8n-packages/entities/workflow/static-sub-workflow-id.js.map +1 -0
  468. package/dist/modules/n8n-packages/entities/workflow/workflow-import.types.d.ts +2 -2
  469. package/dist/modules/n8n-packages/entities/workflow/workflow-importer.js +1 -1
  470. package/dist/modules/n8n-packages/entities/workflow/workflow-importer.js.map +1 -1
  471. package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.d.ts +2 -2
  472. package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.js +5 -4
  473. package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.js.map +1 -1
  474. package/dist/modules/n8n-packages/entities/workflow/workflow-publishing-policy.types.d.ts +1 -1
  475. package/dist/modules/n8n-packages/entities/workflow/workflow-requirements.extractor.js +2 -2
  476. package/dist/modules/n8n-packages/entities/workflow/workflow-requirements.extractor.js.map +1 -1
  477. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js +3 -1
  478. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js.map +1 -1
  479. package/dist/modules/n8n-packages/io/unique-filename-allocator.d.ts +1 -0
  480. package/dist/modules/n8n-packages/io/unique-filename-allocator.js +9 -0
  481. package/dist/modules/n8n-packages/io/unique-filename-allocator.js.map +1 -1
  482. package/dist/modules/n8n-packages/n8n-packages.service.d.ts +8 -4
  483. package/dist/modules/n8n-packages/n8n-packages.service.js +81 -36
  484. package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -1
  485. package/dist/modules/n8n-packages/n8n-packages.types.d.ts +40 -3
  486. package/dist/modules/n8n-packages/n8n-packages.types.js +9 -1
  487. package/dist/modules/n8n-packages/n8n-packages.types.js.map +1 -1
  488. package/dist/modules/n8n-packages/spec/manifest.schema.d.ts +51 -0
  489. package/dist/modules/n8n-packages/spec/requirements.schema.d.ts +45 -0
  490. package/dist/modules/n8n-packages/spec/requirements.schema.js +10 -1
  491. package/dist/modules/n8n-packages/spec/requirements.schema.js.map +1 -1
  492. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js +1 -1
  493. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js.map +1 -1
  494. package/dist/modules/oauth-server/database/repositories/oauth-access-token.repository.d.ts +10 -2
  495. package/dist/modules/oauth-server/database/repositories/oauth-access-token.repository.js +5 -1
  496. package/dist/modules/oauth-server/database/repositories/oauth-access-token.repository.js.map +1 -1
  497. package/dist/modules/oauth-server/database/repositories/oauth-refresh-token.repository.d.ts +14 -2
  498. package/dist/modules/oauth-server/database/repositories/oauth-refresh-token.repository.js +16 -1
  499. package/dist/modules/oauth-server/database/repositories/oauth-refresh-token.repository.js.map +1 -1
  500. package/dist/modules/oauth-server/oauth-token.service.d.ts +3 -2
  501. package/dist/modules/oauth-server/oauth-token.service.js +13 -33
  502. package/dist/modules/oauth-server/oauth-token.service.js.map +1 -1
  503. package/dist/modules/oauth-server/oauth.controller.d.ts +3 -0
  504. package/dist/modules/oauth-server/oauth.controller.js +45 -1
  505. package/dist/modules/oauth-server/oauth.controller.js.map +1 -1
  506. package/dist/modules/oauth-server/oauth.helpers.d.ts +1 -0
  507. package/dist/modules/oauth-server/oauth.helpers.js +7 -0
  508. package/dist/modules/oauth-server/oauth.helpers.js.map +1 -1
  509. package/dist/modules/otel/otel-settings.controller.d.ts +2 -2
  510. package/dist/modules/otel/otel-settings.controller.js +1 -1
  511. package/dist/modules/otel/otel-settings.controller.js.map +1 -1
  512. package/dist/modules/redaction/redaction-context-hook.js +4 -2
  513. package/dist/modules/redaction/redaction-context-hook.js.map +1 -1
  514. package/dist/modules/source-control.ee/source-control-export.service.ee.js +3 -3
  515. package/dist/modules/source-control.ee/source-control-export.service.ee.js.map +1 -1
  516. package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +1 -0
  517. package/dist/modules/source-control.ee/source-control-import.service.ee.js +51 -22
  518. package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
  519. package/dist/modules/source-control.ee/source-control-scoped.service.js +1 -1
  520. package/dist/modules/source-control.ee/source-control-scoped.service.js.map +1 -1
  521. package/dist/modules/source-control.ee/types/exportable-credential.d.ts +2 -0
  522. package/dist/modules/workflow-index/workflow-dependency-query.service.js +1 -1
  523. package/dist/modules/workflow-index/workflow-dependency-query.service.js.map +1 -1
  524. package/dist/modules/workflow-reviews.ee/workflow-review-request.service.d.ts +44 -0
  525. package/dist/modules/workflow-reviews.ee/workflow-review-request.service.js +373 -0
  526. package/dist/modules/workflow-reviews.ee/workflow-review-request.service.js.map +1 -0
  527. package/dist/modules/workflow-reviews.ee/workflow-review-requests.controller.d.ts +14 -0
  528. package/dist/modules/workflow-reviews.ee/workflow-review-requests.controller.js +97 -0
  529. package/dist/modules/workflow-reviews.ee/workflow-review-requests.controller.js.map +1 -0
  530. package/dist/modules/workflow-reviews.ee/workflow-reviews.module.d.ts +4 -0
  531. package/dist/modules/workflow-reviews.ee/workflow-reviews.module.js +24 -0
  532. package/dist/modules/workflow-reviews.ee/workflow-reviews.module.js.map +1 -0
  533. package/dist/node-execution/ephemeral-node-executor.d.ts +5 -1
  534. package/dist/node-execution/ephemeral-node-executor.js +7 -4
  535. package/dist/node-execution/ephemeral-node-executor.js.map +1 -1
  536. package/dist/node-execution/index.d.ts +1 -0
  537. package/dist/node-execution/index.js +4 -1
  538. package/dist/node-execution/index.js.map +1 -1
  539. package/dist/node-execution/node-tool-operation-support.d.ts +2 -0
  540. package/dist/node-execution/node-tool-operation-support.js +12 -0
  541. package/dist/node-execution/node-tool-operation-support.js.map +1 -0
  542. package/dist/node-types.d.ts +5 -1
  543. package/dist/node-types.js +53 -20
  544. package/dist/node-types.js.map +1 -1
  545. package/dist/oauth/oauth.service.d.ts +5 -1
  546. package/dist/oauth/oauth.service.js +57 -28
  547. package/dist/oauth/oauth.service.js.map +1 -1
  548. package/dist/permissions.ee/check-access.js +18 -0
  549. package/dist/permissions.ee/check-access.js.map +1 -1
  550. package/dist/posthog/index.js +6 -0
  551. package/dist/posthog/index.js.map +1 -1
  552. package/dist/public-api/index.d.ts +1 -1
  553. package/dist/public-api/index.js +40 -11
  554. package/dist/public-api/index.js.map +1 -1
  555. package/dist/public-api/types.d.ts +7 -1
  556. package/dist/public-api/v1/controllers/index.d.ts +2 -0
  557. package/dist/public-api/v1/controllers/index.js +5 -0
  558. package/dist/public-api/v1/controllers/index.js.map +1 -0
  559. package/dist/public-api/v1/controllers/workflows.public.controller.d.ts +9 -0
  560. package/dist/public-api/v1/controllers/workflows.public.controller.js +81 -0
  561. package/dist/public-api/v1/controllers/workflows.public.controller.js.map +1 -0
  562. package/dist/public-api/v1/handlers/credentials/credentials.handler.js +1 -0
  563. package/dist/public-api/v1/handlers/credentials/credentials.handler.js.map +1 -1
  564. package/dist/public-api/v1/handlers/credentials/credentials.service.d.ts +1 -0
  565. package/dist/public-api/v1/handlers/credentials/credentials.service.js +9 -2
  566. package/dist/public-api/v1/handlers/credentials/credentials.service.js.map +1 -1
  567. package/dist/public-api/v1/handlers/discover/discover.service.d.ts +1 -0
  568. package/dist/public-api/v1/handlers/discover/discover.service.js +39 -34
  569. package/dist/public-api/v1/handlers/discover/discover.service.js.map +1 -1
  570. package/dist/public-api/v1/handlers/executions/executions.handler.js.map +1 -1
  571. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +8 -3
  572. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -1
  573. package/dist/public-api/v1/handlers/otel/otel.handler.d.ts +9 -0
  574. package/dist/public-api/v1/handlers/otel/otel.handler.js +57 -0
  575. package/dist/public-api/v1/handlers/otel/otel.handler.js.map +1 -0
  576. package/dist/public-api/v1/handlers/otel/otel.mapper.d.ts +3 -0
  577. package/dist/public-api/v1/handlers/otel/otel.mapper.js +18 -0
  578. package/dist/public-api/v1/handlers/otel/otel.mapper.js.map +1 -0
  579. package/dist/public-api/v1/handlers/tags/tags.handler.d.ts +0 -1
  580. package/dist/public-api/v1/handlers/tags/tags.handler.js +0 -8
  581. package/dist/public-api/v1/handlers/tags/tags.handler.js.map +1 -1
  582. package/dist/public-api/v1/handlers/users/users.service.ee.js.map +1 -1
  583. package/dist/public-api/v1/handlers/workflows/workflows.handler.d.ts +2 -0
  584. package/dist/public-api/v1/handlers/workflows/workflows.handler.js +47 -34
  585. package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
  586. package/dist/public-api/v1/handlers/workflows/workflows.service.js +6 -0
  587. package/dist/public-api/v1/handlers/workflows/workflows.service.js.map +1 -1
  588. package/dist/public-api/v1/openapi.yml +491 -19
  589. package/dist/public-api/v1/shared/middlewares/global.middleware.d.ts +4 -0
  590. package/dist/public-api/v1/shared/middlewares/global.middleware.js +9 -1
  591. package/dist/public-api/v1/shared/middlewares/global.middleware.js.map +1 -1
  592. package/dist/public-api/v1/shared/public-api-scope-lookup.d.ts +5 -0
  593. package/dist/public-api/v1/shared/public-api-scope-lookup.js +60 -0
  594. package/dist/public-api/v1/shared/public-api-scope-lookup.js.map +1 -0
  595. package/dist/scaling/constants.d.ts +2 -2
  596. package/dist/scaling/pubsub/pubsub.event-map.d.ts +1 -0
  597. package/dist/scaling/pubsub/pubsub.types.d.ts +2 -1
  598. package/dist/scheduling/durable-job-provisioner.d.ts +1 -0
  599. package/dist/scheduling/durable-job-provisioner.js +2 -0
  600. package/dist/scheduling/durable-job-provisioner.js.map +1 -1
  601. package/dist/scheduling/durable-scheduler.d.ts +2 -1
  602. package/dist/scheduling/durable-scheduler.js +4 -2
  603. package/dist/scheduling/durable-scheduler.js.map +1 -1
  604. package/dist/scheduling/poll-trigger-node/poll-job-provider.d.ts +11 -0
  605. package/dist/scheduling/poll-trigger-node/poll-job-provider.js +41 -0
  606. package/dist/scheduling/poll-trigger-node/poll-job-provider.js.map +1 -0
  607. package/dist/scheduling/poll-trigger-node/poll-trigger-job-registrar.d.ts +19 -0
  608. package/dist/scheduling/poll-trigger-node/poll-trigger-job-registrar.js +111 -0
  609. package/dist/scheduling/poll-trigger-node/poll-trigger-job-registrar.js.map +1 -0
  610. package/dist/scheduling/poll-trigger-node/poll-trigger-task-handler.d.ts +16 -0
  611. package/dist/scheduling/poll-trigger-node/poll-trigger-task-handler.js +100 -0
  612. package/dist/scheduling/poll-trigger-node/poll-trigger-task-handler.js.map +1 -0
  613. package/dist/scheduling/poll-trigger-node/poll-trigger-task.d.ts +6 -0
  614. package/dist/scheduling/poll-trigger-node/poll-trigger-task.js +8 -0
  615. package/dist/scheduling/poll-trigger-node/poll-trigger-task.js.map +1 -0
  616. package/dist/scheduling/schedule-trigger-node/schedule-trigger-job-registrar.d.ts +1 -0
  617. package/dist/scheduling/schedule-trigger-node/schedule-trigger-job-registrar.js +7 -1
  618. package/dist/scheduling/schedule-trigger-node/schedule-trigger-job-registrar.js.map +1 -1
  619. package/dist/security-audit/risk-reporters/credentials-risk-reporter.d.ts +4 -6
  620. package/dist/security-audit/risk-reporters/credentials-risk-reporter.js +17 -23
  621. package/dist/security-audit/risk-reporters/credentials-risk-reporter.js.map +1 -1
  622. package/dist/security-audit/security-audit.repository.js.map +1 -1
  623. package/dist/services/export.service.js.map +1 -1
  624. package/dist/services/folder-finder.service.d.ts +1 -0
  625. package/dist/services/folder-finder.service.js +30 -0
  626. package/dist/services/folder-finder.service.js.map +1 -1
  627. package/dist/services/folder.service.js.map +1 -1
  628. package/dist/services/free-ai-credits.service.d.ts +32 -0
  629. package/dist/services/free-ai-credits.service.js +55 -0
  630. package/dist/services/free-ai-credits.service.js.map +1 -0
  631. package/dist/services/frontend.service.js +2 -0
  632. package/dist/services/frontend.service.js.map +1 -1
  633. package/dist/services/hooks.service.js.map +1 -1
  634. package/dist/services/import.service.js +3 -1
  635. package/dist/services/import.service.js.map +1 -1
  636. package/dist/services/ownership-transfer/ownership-transfer-handler.registry.js.map +1 -1
  637. package/dist/services/ownership-transfer/ownership-transfer.manifest.json +5 -0
  638. package/dist/services/project.service.ee.d.ts +1 -0
  639. package/dist/services/project.service.ee.js +6 -1
  640. package/dist/services/project.service.ee.js.map +1 -1
  641. package/dist/services/public-api-key.service.js.map +1 -1
  642. package/dist/services/role.service.d.ts +2 -1
  643. package/dist/services/role.service.js +21 -3
  644. package/dist/services/role.service.js.map +1 -1
  645. package/dist/services/tag.service.js.map +1 -1
  646. package/dist/telemetry/index.d.ts +3 -2
  647. package/dist/telemetry/index.js +7 -1
  648. package/dist/telemetry/index.js.map +1 -1
  649. package/dist/utils.d.ts +1 -0
  650. package/dist/utils.js +4 -0
  651. package/dist/utils.js.map +1 -1
  652. package/dist/webhooks/live-webhooks.js +1 -1
  653. package/dist/webhooks/live-webhooks.js.map +1 -1
  654. package/dist/webhooks/waiting-forms.js +2 -7
  655. package/dist/webhooks/waiting-forms.js.map +1 -1
  656. package/dist/webhooks/waiting-webhooks.d.ts +7 -2
  657. package/dist/webhooks/waiting-webhooks.js +32 -2
  658. package/dist/webhooks/waiting-webhooks.js.map +1 -1
  659. package/dist/workflow-helpers.js +8 -62
  660. package/dist/workflow-helpers.js.map +1 -1
  661. package/dist/workflows/publication/workflow-publication-reconciler.service.d.ts +10 -3
  662. package/dist/workflows/publication/workflow-publication-reconciler.service.js +49 -13
  663. package/dist/workflows/publication/workflow-publication-reconciler.service.js.map +1 -1
  664. package/dist/workflows/triggers/non-webhook-trigger-registrar.d.ts +3 -1
  665. package/dist/workflows/triggers/non-webhook-trigger-registrar.js +5 -2
  666. package/dist/workflows/triggers/non-webhook-trigger-registrar.js.map +1 -1
  667. package/dist/workflows/triggers/trigger-execution-context.factory.d.ts +13 -4
  668. package/dist/workflows/triggers/trigger-execution-context.factory.js +62 -4
  669. package/dist/workflows/triggers/trigger-execution-context.factory.js.map +1 -1
  670. package/dist/workflows/workflow-creation.service.js +8 -2
  671. package/dist/workflows/workflow-creation.service.js.map +1 -1
  672. package/dist/workflows/workflow-finder.service.js +1 -0
  673. package/dist/workflows/workflow-finder.service.js.map +1 -1
  674. package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
  675. package/dist/workflows/workflow-sharing.service.js.map +1 -1
  676. package/dist/workflows/workflow-validation.service.js +1 -1
  677. package/dist/workflows/workflow-validation.service.js.map +1 -1
  678. package/dist/workflows/workflow.service.d.ts +5 -2
  679. package/dist/workflows/workflow.service.ee.js +1 -0
  680. package/dist/workflows/workflow.service.ee.js.map +1 -1
  681. package/dist/workflows/workflow.service.js +54 -12
  682. package/dist/workflows/workflow.service.js.map +1 -1
  683. package/dist/workflows/workflows.controller.js.map +1 -1
  684. package/package.json +36 -35
  685. package/dist/blob-storage/azure-byte-store.ee.d.ts +0 -10
  686. package/dist/blob-storage/azure-byte-store.ee.js +0 -42
  687. package/dist/blob-storage/azure-byte-store.ee.js.map +0 -1
  688. package/dist/blob-storage/fs-byte-store.d.ts +0 -14
  689. package/dist/blob-storage/fs-byte-store.js +0 -96
  690. package/dist/blob-storage/fs-byte-store.js.map +0 -1
  691. package/dist/blob-storage/json-store.d.ts +0 -18
  692. package/dist/blob-storage/json-store.js +0 -128
  693. package/dist/blob-storage/json-store.js.map +0 -1
  694. package/dist/blob-storage/s3-byte-store.ee.d.ts +0 -10
  695. package/dist/blob-storage/s3-byte-store.ee.js +0 -37
  696. package/dist/blob-storage/s3-byte-store.ee.js.map +0 -1
  697. package/dist/blob-storage/skipped-entry-deletion.error.d.ts +0 -5
  698. package/dist/blob-storage/skipped-entry-deletion.error.js +0 -13
  699. package/dist/blob-storage/skipped-entry-deletion.error.js.map +0 -1
  700. package/dist/blob-storage/types.d.ts +0 -23
  701. package/dist/blob-storage/types.js.map +0 -1
  702. package/dist/modules/agents/builder/interactive/llm-provider-defaults.js.map +0 -1
  703. package/dist/modules/agents/builder/skills/integrations.skill.d.ts +0 -2
  704. package/dist/modules/agents/builder/skills/integrations.skill.js +0 -128
  705. package/dist/modules/agents/builder/skills/integrations.skill.js.map +0 -1
  706. package/dist/modules/agents/builder/skills/mcp.skill.d.ts +0 -2
  707. package/dist/modules/agents/builder/skills/mcp.skill.js +0 -172
  708. package/dist/modules/agents/builder/skills/mcp.skill.js.map +0 -1
  709. package/dist/modules/agents/builder/skills/node-tools.skill.d.ts +0 -2
  710. package/dist/modules/agents/builder/skills/node-tools.skill.js +0 -90
  711. package/dist/modules/agents/builder/skills/node-tools.skill.js.map +0 -1
@@ -10,26 +10,43 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  var InstanceAiSettingsService_1;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.InstanceAiSettingsService = void 0;
13
+ exports.InstanceAiSettingsService = exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY = exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY = exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY = exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY = void 0;
14
+ const node_util_1 = require("node:util");
14
15
  const api_types_1 = require("@n8n/api-types");
15
16
  const backend_common_1 = require("@n8n/backend-common");
16
17
  const config_1 = require("@n8n/config");
17
18
  const db_1 = require("@n8n/db");
18
19
  const di_1 = require("@n8n/di");
20
+ const permissions_1 = require("@n8n/permissions");
21
+ const ensure_error_1 = require("@n8n/utils/errors/ensure-error");
19
22
  const n8n_workflow_1 = require("n8n-workflow");
20
23
  const credentials_finder_service_1 = require("../../credentials/credentials-finder.service");
21
24
  const credentials_service_1 = require("../../credentials/credentials.service");
25
+ const instance_credential_broker_1 = require("../../credentials/instance-credential-broker");
26
+ const conflict_error_1 = require("../../errors/response-errors/conflict.error");
27
+ const forbidden_error_1 = require("../../errors/response-errors/forbidden.error");
22
28
  const unprocessable_error_1 = require("../../errors/response-errors/unprocessable.error");
23
29
  const event_service_1 = require("../../events/event.service");
24
30
  const ai_service_1 = require("../../services/ai.service");
25
31
  const user_service_1 = require("../../services/user.service");
26
32
  const sandbox_provider_1 = require("./sandbox-provider");
27
33
  const ADMIN_SETTINGS_KEY = 'instanceAi.settings';
34
+ const N8N_SANDBOX_HEADER_NAME = 'x-api-key';
35
+ const MODEL_PROVIDER_API_KEY_ENV = new Map([
36
+ ['anthropic', 'ANTHROPIC_API_KEY'],
37
+ ['cohere', 'COHERE_API_KEY'],
38
+ ['deepseek', 'DEEPSEEK_API_KEY'],
39
+ ['google', 'GOOGLE_GENERATIVE_AI_API_KEY'],
40
+ ['groq', 'GROQ_API_KEY'],
41
+ ['mistral', 'MISTRAL_API_KEY'],
42
+ ['openai', 'OPENAI_API_KEY'],
43
+ ['openrouter', 'OPENROUTER_API_KEY'],
44
+ ['xai', 'XAI_API_KEY'],
45
+ ]);
28
46
  const CREDENTIAL_TO_MODEL_PROVIDER = {
29
47
  openAiApi: 'openai',
30
48
  anthropicApi: 'anthropic',
31
49
  googlePalmApi: 'google',
32
- ollamaApi: 'ollama',
33
50
  groqApi: 'groq',
34
51
  deepSeekApi: 'deepseek',
35
52
  mistralCloudApi: 'mistral',
@@ -37,33 +54,130 @@ const CREDENTIAL_TO_MODEL_PROVIDER = {
37
54
  openRouterApi: 'openrouter',
38
55
  cohereApi: 'cohere',
39
56
  };
40
- const SUPPORTED_CREDENTIAL_TYPES = Object.keys(CREDENTIAL_TO_MODEL_PROVIDER);
41
57
  const URL_FIELD_MAP = {
42
58
  openAiApi: 'url',
43
59
  anthropicApi: 'url',
44
60
  googlePalmApi: 'host',
45
- ollamaApi: 'baseUrl',
46
61
  };
47
- const SANDBOX_CREDENTIAL_TYPES = ['daytonaApi', 'httpHeaderAuth'];
48
- const SEARCH_CREDENTIAL_TYPES = ['braveSearchApi', 'searXngApi'];
49
- const SERVICE_CREDENTIAL_TYPES = [...SANDBOX_CREDENTIAL_TYPES, ...SEARCH_CREDENTIAL_TYPES];
62
+ function requireConnectionValue(type, data, field) {
63
+ const value = data[field];
64
+ if (typeof value !== 'string' || value.trim().length === 0) {
65
+ throw new unprocessable_error_1.UnprocessableRequestError(`The field "${field}" is required for provider connection type "${type}"`);
66
+ }
67
+ return value.trim();
68
+ }
69
+ function requireHttpUrl(type, data, field) {
70
+ const value = requireConnectionValue(type, data, field);
71
+ try {
72
+ const url = new URL(value);
73
+ if (url.protocol === 'http:' || url.protocol === 'https:')
74
+ return;
75
+ }
76
+ catch { }
77
+ throw new unprocessable_error_1.UnprocessableRequestError(`The field "${field}" must be a valid HTTP URL for provider connection type "${type}"`);
78
+ }
79
+ function validateModelCredential({ type, data, }) {
80
+ const apiKey = data.apiKey;
81
+ if (typeof apiKey === 'string' && apiKey.trim().length > 0)
82
+ return;
83
+ const urlField = URL_FIELD_MAP[type];
84
+ const url = urlField === undefined ? undefined : data[urlField];
85
+ if (typeof url === 'string' && url.trim().length > 0)
86
+ return;
87
+ throw new unprocessable_error_1.UnprocessableRequestError(urlField === undefined
88
+ ? `The field "apiKey" is required for provider connection type "${type}"`
89
+ : `The field "apiKey" or "${urlField}" is required for provider connection type "${type}"`);
90
+ }
91
+ function modelCredentialHeaders(credentialType, data) {
92
+ const headers = {};
93
+ if (credentialType === 'openAiApi' && typeof data.organizationId === 'string') {
94
+ const organizationId = data.organizationId.trim();
95
+ if (organizationId)
96
+ headers['OpenAI-Organization'] = organizationId;
97
+ }
98
+ if ((credentialType === 'openAiApi' || credentialType === 'anthropicApi') &&
99
+ data.header === true &&
100
+ typeof data.headerName === 'string' &&
101
+ typeof data.headerValue === 'string') {
102
+ const headerName = data.headerName.trim();
103
+ if (headerName)
104
+ headers[headerName] = data.headerValue;
105
+ }
106
+ return Object.keys(headers).length ? headers : undefined;
107
+ }
108
+ function validateSandboxServiceCredential({ type, data, }) {
109
+ const headerName = requireConnectionValue(type, data, 'name').toLowerCase();
110
+ if (headerName !== N8N_SANDBOX_HEADER_NAME) {
111
+ throw new unprocessable_error_1.UnprocessableRequestError(`The credential's header name must be "${N8N_SANDBOX_HEADER_NAME}" but is "${headerName}"`);
112
+ }
113
+ requireConnectionValue(type, data, 'value');
114
+ }
115
+ function validateDaytonaCredential({ type, data, }) {
116
+ requireHttpUrl(type, data, 'apiUrl');
117
+ requireConnectionValue(type, data, 'apiKey');
118
+ }
119
+ function validateSearchCredential({ type, data, }) {
120
+ if (type === 'searXngApi')
121
+ requireHttpUrl(type, data, 'apiUrl');
122
+ else
123
+ requireConnectionValue(type, data, 'apiKey');
124
+ }
125
+ exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY = {
126
+ id: 'instance-ai:model',
127
+ credentialTypes: api_types_1.INSTANCE_AI_MODEL_CREDENTIAL_TYPES,
128
+ validate: validateModelCredential,
129
+ };
130
+ exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY = {
131
+ id: 'instance-ai:sandbox:daytona',
132
+ credentialTypes: ['daytonaApi'],
133
+ validate: validateDaytonaCredential,
134
+ };
135
+ exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY = {
136
+ id: 'instance-ai:sandbox:n8n',
137
+ credentialTypes: ['httpHeaderAuth'],
138
+ validate: validateSandboxServiceCredential,
139
+ };
140
+ exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY = {
141
+ id: 'instance-ai:search',
142
+ credentialTypes: api_types_1.INSTANCE_AI_SEARCH_CREDENTIAL_TYPES,
143
+ validate: validateSearchCredential,
144
+ };
145
+ function validateInstanceAiCredential(policy, credential) {
146
+ if (policy === exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY) {
147
+ validateModelCredential(credential);
148
+ }
149
+ else if (policy === exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY) {
150
+ validateDaytonaCredential(credential);
151
+ }
152
+ else if (policy === exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY) {
153
+ validateSandboxServiceCredential(credential);
154
+ }
155
+ else if (policy === exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY) {
156
+ validateSearchCredential(credential);
157
+ }
158
+ else {
159
+ throw new n8n_workflow_1.UnexpectedError(`Unknown instance AI credential policy "${policy.id}"`);
160
+ }
161
+ }
50
162
  let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSettingsService {
51
- constructor(globalConfig, settingsRepository, userRepository, userService, aiService, credentialsService, credentialsFinderService, eventService) {
163
+ constructor(globalConfig, dbLockService, settingsRepository, userRepository, userService, aiService, credentialsService, credentialsFinderService, instanceCredentialBroker, eventService) {
164
+ this.dbLockService = dbLockService;
52
165
  this.settingsRepository = settingsRepository;
53
166
  this.userRepository = userRepository;
54
167
  this.userService = userService;
55
168
  this.aiService = aiService;
56
169
  this.credentialsService = credentialsService;
57
170
  this.credentialsFinderService = credentialsFinderService;
171
+ this.instanceCredentialBroker = instanceCredentialBroker;
58
172
  this.eventService = eventService;
59
173
  this.enabled = true;
60
174
  this.mcpAccessEnabled = true;
61
175
  this.permissions = { ...api_types_1.DEFAULT_INSTANCE_AI_PERMISSIONS };
62
- this.adminDaytonaCredentialId = null;
63
- this.adminN8nSandboxCredentialId = null;
64
- this.adminSearchCredentialId = null;
176
+ this.adminModelName = null;
65
177
  this.config = globalConfig.instanceAi;
66
178
  this.deploymentConfig = globalConfig.deployment;
179
+ this.environmentSandboxProvider = (0, sandbox_provider_1.normalizeSandboxProvider)(this.config.sandboxProvider);
180
+ this.config.sandboxProvider = this.environmentSandboxProvider;
67
181
  }
68
182
  get isCloud() {
69
183
  return this.deploymentConfig.type === 'cloud';
@@ -77,13 +191,7 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
77
191
  sandboxEnabled: this.config.sandboxEnabled,
78
192
  sandboxProvider: this.config.sandboxProvider,
79
193
  };
80
- const row = await this.settingsRepository.findByKey(ADMIN_SETTINGS_KEY);
81
- if (row) {
82
- const persisted = (0, n8n_workflow_1.jsonParse)(row.value, {
83
- fallbackValue: {},
84
- });
85
- this.applyAdminSettings(persisted);
86
- }
194
+ await this.reloadFromDb();
87
195
  const c = this.config;
88
196
  const overridden = c.sandboxEnabled !== envSnapshot.sandboxEnabled ||
89
197
  c.sandboxProvider !== envSnapshot.sandboxProvider;
@@ -97,62 +205,334 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
97
205
  logger.warn(`Sandbox unavailable: ${sandboxStatus.unavailableReason}`);
98
206
  }
99
207
  }
100
- getAdminSettings() {
208
+ async getAdminSettings() {
209
+ const isManaged = this.isCloud || this.aiService.isProxyEnabled();
210
+ if (isManaged) {
211
+ return this.buildAdminSettingsResponse({
212
+ modelCredentialId: null,
213
+ modelName: null,
214
+ daytonaCredentialId: null,
215
+ n8nSandboxCredentialId: null,
216
+ searchCredentialId: null,
217
+ });
218
+ }
219
+ const [modelSelection, daytonaCredentialId, n8nSandboxCredentialId, searchCredentialId] = await Promise.all([
220
+ this.readAdminModelSelection(),
221
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY),
222
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY),
223
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY),
224
+ ]);
225
+ return this.buildAdminSettingsResponse({
226
+ ...modelSelection,
227
+ daytonaCredentialId,
228
+ n8nSandboxCredentialId,
229
+ searchCredentialId,
230
+ });
231
+ }
232
+ buildAdminSettingsResponse(credentialSelection) {
101
233
  const c = this.config;
234
+ const modelProviderApiKeyEnv = MODEL_PROVIDER_API_KEY_ENV.get(c.model.split('/', 1)[0] ?? '');
235
+ const isManaged = this.isCloud || this.aiService.isProxyEnabled();
102
236
  return {
103
237
  enabled: this.enabled,
104
238
  permissions: { ...this.permissions },
105
- mcpServers: c.mcpServers,
106
239
  mcpAccessEnabled: this.mcpAccessEnabled,
107
240
  sandboxEnabled: c.sandboxEnabled,
108
- sandboxProvider: (0, sandbox_provider_1.normalizeSandboxProvider)(c.sandboxProvider),
109
- sandboxImage: c.sandboxImage,
110
- sandboxTimeout: c.sandboxTimeout,
111
- daytonaCredentialId: this.adminDaytonaCredentialId,
112
- n8nSandboxCredentialId: this.adminN8nSandboxCredentialId,
113
- searchCredentialId: this.adminSearchCredentialId,
241
+ sandboxProvider: this.aiService.isProxyEnabled()
242
+ ? 'daytona'
243
+ : (0, sandbox_provider_1.normalizeSandboxProvider)(c.sandboxProvider),
244
+ daytonaCredentialId: isManaged ? null : credentialSelection.daytonaCredentialId,
245
+ n8nSandboxCredentialId: isManaged ? null : credentialSelection.n8nSandboxCredentialId,
246
+ searchCredentialId: isManaged ? null : credentialSelection.searchCredentialId,
247
+ modelCredentialId: isManaged ? null : credentialSelection.modelCredentialId,
248
+ modelName: isManaged ? null : credentialSelection.modelName,
249
+ modelEnvConfigured: Boolean(c.modelApiKey.trim() ||
250
+ c.modelUrl.trim() ||
251
+ (modelProviderApiKeyEnv && process.env[modelProviderApiKeyEnv]?.trim())),
252
+ sandboxEnvConfigured: this.environmentSandboxProvider === 'daytona'
253
+ ? Boolean(c.daytonaApiKey.trim())
254
+ : Boolean(c.n8nSandboxServiceUrl.trim()),
255
+ searchEnvConfigured: Boolean(c.braveSearchApiKey.trim() || c.searxngUrl.trim()),
114
256
  localGatewayDisabled: this.isLocalGatewayDisabled(),
115
257
  browserUseEnabled: this.isBrowserUseEnabled(),
116
258
  };
117
259
  }
118
- async updateAdminSettings(update) {
260
+ async updateAdminSettings(update, user) {
119
261
  this.rejectManagedFields(update, InstanceAiSettingsService_1.MANAGED_ADMIN_FIELDS, this.deploymentLabel());
120
- this.validateAdminSettingsUpdate(update);
121
- const c = this.config;
122
- const previousMcpServers = c.mcpServers;
123
- const previousMcpAccessEnabled = this.mcpAccessEnabled;
124
- if (update.enabled !== undefined)
125
- this.enabled = update.enabled;
126
- if (update.permissions) {
127
- this.permissions = { ...this.permissions, ...update.permissions };
128
- }
129
- if (update.mcpServers !== undefined)
130
- c.mcpServers = update.mcpServers;
131
- if (update.mcpAccessEnabled !== undefined)
132
- this.mcpAccessEnabled = update.mcpAccessEnabled;
133
- if (update.sandboxEnabled !== undefined)
134
- c.sandboxEnabled = update.sandboxEnabled;
135
- if (update.sandboxProvider !== undefined)
136
- c.sandboxProvider = update.sandboxProvider;
137
- if (update.sandboxImage !== undefined)
138
- c.sandboxImage = update.sandboxImage;
139
- if (update.sandboxTimeout !== undefined)
140
- c.sandboxTimeout = update.sandboxTimeout;
141
- if (update.daytonaCredentialId !== undefined)
142
- this.adminDaytonaCredentialId = update.daytonaCredentialId;
143
- if (update.n8nSandboxCredentialId !== undefined)
144
- this.adminN8nSandboxCredentialId = update.n8nSandboxCredentialId;
145
- if (update.searchCredentialId !== undefined)
146
- this.adminSearchCredentialId = update.searchCredentialId;
147
- if (update.localGatewayDisabled !== undefined)
148
- c.localGatewayDisabled = update.localGatewayDisabled;
149
- if (update.browserUseEnabled !== undefined)
150
- c.browserUseEnabled = update.browserUseEnabled;
151
- await this.persistAdminSettings();
152
- this.eventService.emit('instance-ai-settings-updated', {
153
- mcpSettingsChanged: c.mcpServers !== previousMcpServers || this.mcpAccessEnabled !== previousMcpAccessEnabled,
262
+ if (this.isCloud || this.aiService.isProxyEnabled()) {
263
+ this.rejectManagedFields(update, InstanceAiSettingsService_1.INSTANCE_CREDENTIAL_FIELDS, this.deploymentLabel());
264
+ this.rejectManagedFields(update, ['modelName', 'sandboxProvider'], this.deploymentLabel());
265
+ }
266
+ const { modelCredentialId: initialModelCredentialId, daytonaCredentialId: initialDaytonaCredentialId, n8nSandboxCredentialId: initialN8nSandboxCredentialId, searchCredentialId: initialSearchCredentialId, modelConnection, sandboxConnection, searchConnection, ...settingsUpdate } = update;
267
+ let modelCredentialId = initialModelCredentialId;
268
+ let daytonaCredentialId = initialDaytonaCredentialId;
269
+ let n8nSandboxCredentialId = initialN8nSandboxCredentialId;
270
+ let searchCredentialId = initialSearchCredentialId;
271
+ this.rejectConnectionConflicts(update);
272
+ if (modelConnection !== undefined ||
273
+ sandboxConnection !== undefined ||
274
+ searchConnection !== undefined) {
275
+ if (!user || !(0, permissions_1.hasGlobalScope)(user, 'credential:manageInstance')) {
276
+ throw new forbidden_error_1.ForbiddenError('You do not have permission to manage provider connections');
277
+ }
278
+ }
279
+ if (modelConnection) {
280
+ const modelName = settingsUpdate.modelName === undefined
281
+ ? (await this.readAdminModelSelection()).modelName
282
+ : settingsUpdate.modelName;
283
+ if (modelName === null) {
284
+ throw new unprocessable_error_1.UnprocessableRequestError('modelName must be set together with modelCredentialId');
285
+ }
286
+ }
287
+ const [modelPrepared, searchPrepared, sandboxPrepared] = user
288
+ ? await Promise.all([
289
+ this.prepareConnection(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, 'AI Assistant model', modelConnection),
290
+ this.prepareConnection(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, 'AI Assistant web search', searchConnection),
291
+ this.prepareSandboxConnection(sandboxConnection),
292
+ ])
293
+ : [undefined, undefined, undefined];
294
+ this.validateAdminSettingsUpdate(update, this.snapshotAdminSettings(), sandboxConnection === null
295
+ ? this.environmentSandboxProvider
296
+ : sandboxConnection?.type === 'daytonaApi'
297
+ ? 'daytona'
298
+ : sandboxConnection?.type === 'httpHeaderAuth'
299
+ ? 'n8n-sandbox'
300
+ : settingsUpdate.sandboxProvider);
301
+ await this.runConnectionHooks([modelPrepared, searchPrepared, sandboxPrepared]);
302
+ const { previous, next, credentialSelection } = await this.dbLockService.withLockContext(1007, async (ctx) => {
303
+ if (user && modelConnection !== undefined) {
304
+ modelCredentialId = await this.upsertConnection(user, exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, 'AI Assistant model', modelConnection, ctx, modelPrepared);
305
+ }
306
+ if (user && searchConnection !== undefined) {
307
+ searchCredentialId = await this.upsertConnection(user, exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, 'AI Assistant web search', searchConnection, ctx, searchPrepared);
308
+ }
309
+ if (user && sandboxConnection !== undefined) {
310
+ const sandbox = await this.upsertSandboxConnection(user, sandboxConnection, ctx, sandboxPrepared);
311
+ daytonaCredentialId = sandbox.daytonaCredentialId;
312
+ n8nSandboxCredentialId = sandbox.n8nSandboxCredentialId;
313
+ if (sandbox.sandboxProvider)
314
+ settingsUpdate.sandboxProvider = sandbox.sandboxProvider;
315
+ }
316
+ const updateCredentialAssignment = async (credentialUse, credentialId) => {
317
+ if (credentialId === undefined)
318
+ return;
319
+ if (credentialId === null) {
320
+ await this.instanceCredentialBroker.clearForUse(credentialUse, ctx);
321
+ }
322
+ else {
323
+ await this.instanceCredentialBroker.assignForUse(credentialUse, credentialId, ctx);
324
+ }
325
+ };
326
+ const persisted = await this.settingsRepository.findByKeyInContext(ADMIN_SETTINGS_KEY, ctx);
327
+ const current = this.mergeAdminSettings(this.snapshotAdminSettings(), this.parsePersistedAdminSettings(persisted?.value));
328
+ const [currentModelCredentialId, currentDaytonaCredentialId, currentN8nCredentialId, currentSearchCredentialId,] = await Promise.all([
329
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, ctx),
330
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, ctx),
331
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, ctx),
332
+ this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, ctx),
333
+ ]);
334
+ const nextDaytonaCredentialId = daytonaCredentialId === undefined ? currentDaytonaCredentialId : daytonaCredentialId;
335
+ const nextN8nCredentialId = n8nSandboxCredentialId === undefined ? currentN8nCredentialId : n8nSandboxCredentialId;
336
+ const nextSearchCredentialId = searchCredentialId === undefined ? currentSearchCredentialId : searchCredentialId;
337
+ const clearsSandboxConnection = (sandboxConnection !== undefined ||
338
+ daytonaCredentialId !== undefined ||
339
+ n8nSandboxCredentialId !== undefined) &&
340
+ nextDaytonaCredentialId === null &&
341
+ nextN8nCredentialId === null;
342
+ this.validateAdminSettingsUpdate(update, current, clearsSandboxConnection
343
+ ? this.environmentSandboxProvider
344
+ : settingsUpdate.sandboxProvider);
345
+ const previous = this.snapshotAdminSettings();
346
+ const next = this.mergeAdminSettings(current, settingsUpdate);
347
+ if (clearsSandboxConnection)
348
+ delete next.sandboxProvider;
349
+ const nextModelCredentialId = modelCredentialId === undefined ? currentModelCredentialId : modelCredentialId;
350
+ const nextModelName = settingsUpdate.modelName !== undefined
351
+ ? settingsUpdate.modelName
352
+ : modelCredentialId === null
353
+ ? null
354
+ : current.modelName;
355
+ if (modelCredentialId !== undefined || settingsUpdate.modelName !== undefined) {
356
+ const hasCredential = nextModelCredentialId !== null && nextModelCredentialId !== undefined;
357
+ const hasModelName = nextModelName !== null && nextModelName !== undefined;
358
+ if (hasCredential && !hasModelName) {
359
+ throw new unprocessable_error_1.UnprocessableRequestError('modelName must be set together with modelCredentialId');
360
+ }
361
+ if (hasModelName && !hasCredential) {
362
+ throw new unprocessable_error_1.UnprocessableRequestError('modelName requires modelCredentialId');
363
+ }
364
+ }
365
+ next.modelName = nextModelName ?? null;
366
+ await updateCredentialAssignment(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, modelCredentialId);
367
+ await updateCredentialAssignment(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, daytonaCredentialId);
368
+ await updateCredentialAssignment(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, n8nSandboxCredentialId);
369
+ await updateCredentialAssignment(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, searchCredentialId);
370
+ if (typeof modelCredentialId === 'string') {
371
+ await this.validateAssignedServiceCredential(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, ctx);
372
+ }
373
+ if (typeof daytonaCredentialId === 'string') {
374
+ await this.validateAssignedServiceCredential(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, ctx);
375
+ }
376
+ if (typeof n8nSandboxCredentialId === 'string') {
377
+ await this.validateAssignedServiceCredential(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, ctx);
378
+ }
379
+ if (typeof searchCredentialId === 'string') {
380
+ await this.validateAssignedServiceCredential(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, ctx);
381
+ }
382
+ await this.settingsRepository.upsertByKey(ADMIN_SETTINGS_KEY, JSON.stringify(next), true, ctx);
383
+ return {
384
+ previous,
385
+ next,
386
+ credentialSelection: {
387
+ modelCredentialId: nextModelCredentialId ?? null,
388
+ modelName: next.modelName ?? null,
389
+ daytonaCredentialId: nextDaytonaCredentialId,
390
+ n8nSandboxCredentialId: nextN8nCredentialId,
391
+ searchCredentialId: nextSearchCredentialId,
392
+ },
393
+ };
154
394
  });
155
- return this.getAdminSettings();
395
+ this.applyAdminSettings(next);
396
+ this.emitSettingsUpdated(previous, next);
397
+ return this.buildAdminSettingsResponse(credentialSelection);
398
+ }
399
+ rejectConnectionConflicts(update) {
400
+ const conflicts = [
401
+ ['modelConnection', 'modelCredentialId', update.modelCredentialId !== undefined],
402
+ ['sandboxConnection', 'daytonaCredentialId', update.daytonaCredentialId !== undefined],
403
+ ['sandboxConnection', 'n8nSandboxCredentialId', update.n8nSandboxCredentialId !== undefined],
404
+ ['searchConnection', 'searchCredentialId', update.searchCredentialId !== undefined],
405
+ ];
406
+ for (const [connectionField, idField, idPresent] of conflicts) {
407
+ const connectionPresent = update[connectionField] !== undefined;
408
+ if (connectionPresent && idPresent) {
409
+ throw new unprocessable_error_1.UnprocessableRequestError(`Cannot combine ${connectionField} with ${idField} in one update`);
410
+ }
411
+ }
412
+ }
413
+ async upsertConnection(user, policy, name, connection, ctx, prepared) {
414
+ if (connection === null)
415
+ return null;
416
+ if (!prepared?.encryptedData) {
417
+ throw new n8n_workflow_1.UnexpectedError('Prepared provider connection is missing encrypted data');
418
+ }
419
+ let current;
420
+ try {
421
+ current = await this.instanceCredentialBroker.resolveForUse(policy, ctx);
422
+ }
423
+ catch (error) {
424
+ if (!(error instanceof unprocessable_error_1.UnprocessableRequestError))
425
+ throw error;
426
+ current = null;
427
+ }
428
+ if ((current?.id ?? null) !== prepared.expectedCredentialId ||
429
+ current?.name !== prepared.expectedCredentialName ||
430
+ current?.type !== prepared.expectedCredentialType ||
431
+ (current !== null &&
432
+ current !== undefined &&
433
+ !(0, node_util_1.isDeepStrictEqual)(current.data, prepared.expectedCredentialData))) {
434
+ throw new conflict_error_1.ConflictError('Provider connection changed; retry');
435
+ }
436
+ const data = connection.data;
437
+ if (current && current.type === connection.type) {
438
+ await this.credentialsService.updateInstanceCredential(user, current.id, { name: current.name, type: current.type, data }, ctx, { skipExternalHooks: true, encryptedData: prepared.encryptedData });
439
+ return current.id;
440
+ }
441
+ const dto = {
442
+ name,
443
+ type: connection.type,
444
+ data: connection.data,
445
+ usageScope: 'instance',
446
+ };
447
+ const created = await this.credentialsService.createInstanceCredential(dto, user, ctx, {
448
+ skipExternalHooks: true,
449
+ encryptedData: prepared.encryptedData,
450
+ });
451
+ return created.id;
452
+ }
453
+ async prepareConnection(policy, name, connection) {
454
+ if (!connection)
455
+ return undefined;
456
+ if (!policy.credentialTypes.includes(connection.type)) {
457
+ throw new unprocessable_error_1.UnprocessableRequestError(`Connection type "${connection.type}" is not supported for "${policy.id}"`);
458
+ }
459
+ let current;
460
+ try {
461
+ current = await this.instanceCredentialBroker.resolveForUse(policy);
462
+ }
463
+ catch (error) {
464
+ if (!(error instanceof unprocessable_error_1.UnprocessableRequestError))
465
+ throw error;
466
+ current = null;
467
+ }
468
+ const data = current?.type === connection.type
469
+ ? this.credentialsService.unredact(connection.data, current.data, this.credentialsService.getCredentialTypeProperties(connection.type))
470
+ : connection.data;
471
+ validateInstanceAiCredential(policy, { type: connection.type, data });
472
+ const existing = current?.type === connection.type ? { id: current.id, name: current.name } : null;
473
+ return {
474
+ event: existing ? 'update' : 'create',
475
+ expectedCredentialId: current?.id ?? null,
476
+ expectedCredentialName: current?.name,
477
+ expectedCredentialType: current?.type,
478
+ expectedCredentialData: current?.data,
479
+ credential: {
480
+ id: existing?.id ?? null,
481
+ name: existing?.name ?? name,
482
+ type: connection.type,
483
+ data,
484
+ },
485
+ };
486
+ }
487
+ async prepareSandboxConnection(connection) {
488
+ if (!connection)
489
+ return undefined;
490
+ const policy = connection.type === 'daytonaApi'
491
+ ? exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY
492
+ : connection.type === 'httpHeaderAuth'
493
+ ? exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY
494
+ : undefined;
495
+ if (!policy) {
496
+ throw new unprocessable_error_1.UnprocessableRequestError(`Connection type "${connection.type}" is not supported for the sandbox`);
497
+ }
498
+ return await this.prepareConnection(policy, 'AI Assistant sandbox', connection);
499
+ }
500
+ async runConnectionHooks(preparedConnections) {
501
+ for (const prepared of preparedConnections) {
502
+ if (prepared) {
503
+ prepared.encryptedData = await this.credentialsService.runInstanceCredentialHooks(prepared.event, prepared.credential);
504
+ }
505
+ }
506
+ }
507
+ async upsertSandboxConnection(user, connection, ctx, prepared) {
508
+ const name = 'AI Assistant sandbox';
509
+ if (connection === null) {
510
+ return {
511
+ daytonaCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, name, null, ctx),
512
+ n8nSandboxCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, name, null, ctx),
513
+ };
514
+ }
515
+ if (connection.type === 'daytonaApi') {
516
+ return {
517
+ daytonaCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, name, connection, ctx, prepared),
518
+ n8nSandboxCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, name, null, ctx),
519
+ sandboxProvider: 'daytona',
520
+ };
521
+ }
522
+ if (connection.type === 'httpHeaderAuth') {
523
+ return {
524
+ n8nSandboxCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, name, connection, ctx, prepared),
525
+ daytonaCredentialId: await this.upsertConnection(user, exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, name, null, ctx),
526
+ sandboxProvider: 'n8n-sandbox',
527
+ };
528
+ }
529
+ throw new unprocessable_error_1.UnprocessableRequestError(`Connection type "${connection.type}" is not supported for the sandbox`);
530
+ }
531
+ async reloadFromDb() {
532
+ const previous = this.snapshotAdminSettings();
533
+ const persisted = await this.readPersistedAdminSettings();
534
+ this.applyAdminSettings(persisted);
535
+ this.emitSettingsUpdated(previous, this.snapshotAdminSettings());
156
536
  }
157
537
  async getUserPreferences(user) {
158
538
  const prefs = this.readUserPreferences(user);
@@ -189,100 +569,113 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
189
569
  user.settings = { ...(user.settings ?? {}), instanceAi: prefs };
190
570
  return await this.getUserPreferences(user);
191
571
  }
192
- async listModelCredentials(user) {
193
- if (this.aiService.isProxyEnabled())
572
+ async listInstanceModelCredentials() {
573
+ if (this.isCloud || this.aiService.isProxyEnabled())
194
574
  return [];
195
- const allCredentials = await this.credentialsFinderService.findCredentialsForUser(user, [
196
- 'credential:read',
197
- ]);
198
- return allCredentials
199
- .filter((c) => SUPPORTED_CREDENTIAL_TYPES.includes(c.type))
200
- .map((c) => ({
575
+ const instanceCredentials = await this.instanceCredentialBroker.listForUse(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY);
576
+ return instanceCredentials.map((c) => ({
201
577
  id: c.id,
202
578
  name: c.name,
203
579
  type: c.type,
204
- provider: CREDENTIAL_TO_MODEL_PROVIDER[c.type] ?? 'custom',
205
580
  }));
206
581
  }
207
- async listServiceCredentials(user) {
208
- if (this.aiService.isProxyEnabled())
582
+ async listInstanceServiceCredentials() {
583
+ if (this.isCloud || this.aiService.isProxyEnabled())
209
584
  return [];
210
- const allCredentials = await this.credentialsFinderService.findCredentialsForUser(user, [
211
- 'credential:read',
585
+ const credentials = await Promise.all([
586
+ this.instanceCredentialBroker.listForUse(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY),
587
+ this.instanceCredentialBroker.listForUse(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY),
588
+ this.instanceCredentialBroker.listForUse(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY),
212
589
  ]);
213
- return allCredentials
214
- .filter((c) => SERVICE_CREDENTIAL_TYPES.includes(c.type))
215
- .map((c) => ({
590
+ return credentials.flat().map((c) => ({
216
591
  id: c.id,
217
592
  name: c.name,
218
593
  type: c.type,
219
- provider: c.type,
220
594
  }));
221
595
  }
222
- async resolveDaytonaConfig(user) {
223
- const credentialId = this.adminDaytonaCredentialId;
224
- if (!credentialId) {
225
- const { daytonaApiUrl, daytonaApiKey } = this.config;
226
- return {
227
- apiUrl: daytonaApiUrl || undefined,
228
- apiKey: daytonaApiKey || undefined,
229
- };
230
- }
231
- const credential = await this.credentialsFinderService.findCredentialForUser(credentialId, user, ['credential:read']);
232
- if (!credential) {
233
- return {};
234
- }
235
- const data = await this.credentialsService.decrypt(credential, true);
236
- return {
237
- apiUrl: typeof data.apiUrl === 'string' ? data.apiUrl : undefined,
238
- apiKey: typeof data.apiKey === 'string' ? data.apiKey : undefined,
596
+ async resolveDaytonaConfig() {
597
+ const { daytonaApiUrl, daytonaApiKey } = this.config;
598
+ const envConfig = {
599
+ apiUrl: daytonaApiUrl || undefined,
600
+ apiKey: daytonaApiKey || undefined,
239
601
  };
602
+ const resolved = await this.resolveServiceCredential(exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY, 'Daytona sandbox');
603
+ if (!resolved)
604
+ return envConfig;
605
+ const { data } = resolved;
606
+ const apiUrl = typeof data.apiUrl === 'string' ? data.apiUrl : undefined;
607
+ const apiKey = typeof data.apiKey === 'string' ? data.apiKey : undefined;
608
+ if (!apiUrl || !apiKey) {
609
+ this.warnCredentialFallback('Daytona sandbox', exports.INSTANCE_AI_DAYTONA_CREDENTIAL_POLICY.id, 'Credential data is incomplete');
610
+ return envConfig;
611
+ }
612
+ return { apiUrl, apiKey };
240
613
  }
241
- async resolveN8nSandboxConfig(user) {
614
+ async resolveN8nSandboxConfig() {
242
615
  const { n8nSandboxServiceUrl, n8nSandboxServiceApiKey } = this.config;
243
- const credentialId = this.adminN8nSandboxCredentialId;
244
- if (!credentialId) {
245
- return {
246
- serviceUrl: n8nSandboxServiceUrl || undefined,
247
- apiKey: n8nSandboxServiceApiKey || undefined,
248
- };
249
- }
250
- const credential = await this.credentialsFinderService.findCredentialForUser(credentialId, user, ['credential:read']);
251
- if (!credential) {
252
- return {
253
- serviceUrl: n8nSandboxServiceUrl || undefined,
254
- apiKey: n8nSandboxServiceApiKey || undefined,
255
- };
256
- }
257
- const data = await this.credentialsService.decrypt(credential, true);
258
- const headerName = typeof data.name === 'string' ? data.name.trim().toLowerCase() : '';
259
- const apiKey = typeof data.value === 'string' ? data.value : undefined;
260
- return {
616
+ const envConfig = {
261
617
  serviceUrl: n8nSandboxServiceUrl || undefined,
262
- apiKey: headerName === 'x-api-key' ? apiKey : n8nSandboxServiceApiKey || undefined,
618
+ apiKey: n8nSandboxServiceApiKey || undefined,
263
619
  };
264
- }
265
- async resolveSearchConfig(user) {
266
- const credentialId = this.adminSearchCredentialId;
267
- if (!credentialId) {
268
- const { braveSearchApiKey, searxngUrl } = this.config;
269
- return {
270
- braveApiKey: braveSearchApiKey || undefined,
271
- searxngUrl: searxngUrl || undefined,
272
- };
620
+ const resolved = await this.resolveServiceCredential(exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY, 'n8n Sandbox');
621
+ if (!resolved)
622
+ return envConfig;
623
+ const { data } = resolved;
624
+ const headerName = typeof data.name === 'string' ? data.name.trim().toLowerCase() : '';
625
+ const apiKey = typeof data.value === 'string' ? data.value : undefined;
626
+ if (headerName !== N8N_SANDBOX_HEADER_NAME) {
627
+ this.warnCredentialFallback('n8n Sandbox', exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY.id, `Credential header must be "${N8N_SANDBOX_HEADER_NAME}" but is "${headerName || '(empty)'}"`);
628
+ return envConfig;
273
629
  }
274
- const credential = await this.credentialsFinderService.findCredentialForUser(credentialId, user, ['credential:read']);
275
- if (!credential) {
276
- return {};
630
+ if (!apiKey) {
631
+ this.warnCredentialFallback('n8n Sandbox', exports.INSTANCE_AI_N8N_SANDBOX_CREDENTIAL_POLICY.id, 'Credential data is incomplete');
632
+ return envConfig;
277
633
  }
278
- const data = await this.credentialsService.decrypt(credential, true);
279
- if (credential.type === 'braveSearchApi') {
280
- return { braveApiKey: typeof data.apiKey === 'string' ? data.apiKey : undefined };
634
+ return { serviceUrl: n8nSandboxServiceUrl || undefined, apiKey };
635
+ }
636
+ async resolveSearchConfig() {
637
+ const { braveSearchApiKey, searxngUrl } = this.config;
638
+ const envConfig = {
639
+ braveApiKey: braveSearchApiKey || undefined,
640
+ searxngUrl: searxngUrl || undefined,
641
+ };
642
+ const resolved = await this.resolveServiceCredential(exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY, 'search');
643
+ if (!resolved)
644
+ return envConfig;
645
+ const { type, data } = resolved;
646
+ if (type === 'braveSearchApi' && typeof data.apiKey === 'string' && data.apiKey) {
647
+ return { braveApiKey: data.apiKey };
281
648
  }
282
- if (credential.type === 'searXngApi') {
283
- return { searxngUrl: typeof data.apiUrl === 'string' ? data.apiUrl : undefined };
649
+ if (type === 'searXngApi' && typeof data.apiUrl === 'string' && data.apiUrl) {
650
+ return { searxngUrl: data.apiUrl };
284
651
  }
285
- return {};
652
+ this.warnCredentialFallback('search', exports.INSTANCE_AI_SEARCH_CREDENTIAL_POLICY.id, 'Credential data is incomplete');
653
+ return envConfig;
654
+ }
655
+ async validateAssignedServiceCredential(policy, ctx) {
656
+ const resolved = await this.instanceCredentialBroker.resolveForUse(policy, ctx);
657
+ if (!resolved)
658
+ return;
659
+ validateInstanceAiCredential(policy, { type: resolved.type, data: resolved.data });
660
+ }
661
+ async resolveServiceCredential(policy, service, ctx) {
662
+ if (this.isCloud || this.aiService.isProxyEnabled())
663
+ return null;
664
+ const resolved = ctx
665
+ ? this.instanceCredentialBroker.resolveForUse(policy, ctx)
666
+ : this.instanceCredentialBroker.resolveForUse(policy);
667
+ return await resolved.catch((error) => {
668
+ this.warnCredentialFallback(service, policy.id, (0, ensure_error_1.ensureError)(error).message);
669
+ return null;
670
+ });
671
+ }
672
+ warnCredentialFallback(service, credentialUseId, reason) {
673
+ di_1.Container.get(backend_common_1.Logger)
674
+ .scoped('instance-ai')
675
+ .warn(`Could not resolve the configured ${service} credential; using environment fallback`, {
676
+ credentialUseId,
677
+ error: reason,
678
+ });
286
679
  }
287
680
  getPermissions() {
288
681
  return { ...this.permissions };
@@ -310,7 +703,9 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
310
703
  return this.config.browserUseEnabled;
311
704
  }
312
705
  getSandboxStatus() {
313
- const provider = (0, sandbox_provider_1.normalizeSandboxProvider)(this.config.sandboxProvider);
706
+ const provider = this.aiService.isProxyEnabled()
707
+ ? 'daytona'
708
+ : (0, sandbox_provider_1.normalizeSandboxProvider)(this.config.sandboxProvider);
314
709
  const unavailableReason = this.getSandboxUnavailableReason(this.config.sandboxEnabled, provider);
315
710
  return {
316
711
  enabled: this.config.sandboxEnabled,
@@ -324,10 +719,16 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
324
719
  }
325
720
  resolveModelName(user) {
326
721
  const prefs = this.readUserPreferences(user);
327
- return prefs.modelName ?? this.extractModelName(this.config.model);
722
+ const adminModelName = this.isCloud || this.aiService.isProxyEnabled() ? null : this.adminModelName;
723
+ return adminModelName ?? prefs.modelName ?? this.extractModelName(this.config.model);
328
724
  }
329
725
  async resolveModelConfig(user) {
330
726
  const prefs = this.readUserPreferences(user);
727
+ const fallbackModelName = prefs.modelName ?? this.extractModelName(this.config.model);
728
+ const adminModelConfig = await this.resolveAdminModelConfig();
729
+ if (adminModelConfig) {
730
+ return adminModelConfig;
731
+ }
331
732
  const credentialId = prefs.credentialId ?? null;
332
733
  if (!credentialId) {
333
734
  return this.envVarModelConfig();
@@ -336,24 +737,44 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
336
737
  if (!credential) {
337
738
  return this.envVarModelConfig();
338
739
  }
339
- const provider = CREDENTIAL_TO_MODEL_PROVIDER[credential.type];
740
+ return ((await this.buildModelConfigFromCredential(credential, fallbackModelName)) ??
741
+ this.envVarModelConfig());
742
+ }
743
+ async resolveAdminModelConfig() {
744
+ if (this.isCloud || this.aiService.isProxyEnabled())
745
+ return null;
746
+ return await this.withPersistedAdminSettings(async (ctx, persisted) => {
747
+ const modelName = persisted.modelName ?? null;
748
+ if (!modelName)
749
+ return null;
750
+ const resolved = await this.resolveServiceCredential(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, 'model', ctx);
751
+ if (!resolved)
752
+ return null;
753
+ const config = this.buildModelConfig(resolved.type, resolved.data, modelName);
754
+ if (!config) {
755
+ this.warnCredentialFallback('model', exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY.id, 'Credential data is incomplete');
756
+ }
757
+ return config;
758
+ });
759
+ }
760
+ async buildModelConfigFromCredential(credential, modelName) {
761
+ const data = await this.credentialsService.decrypt(credential, true);
762
+ return this.buildModelConfig(credential.type, data, modelName);
763
+ }
764
+ buildModelConfig(credentialType, data, modelName) {
765
+ const provider = CREDENTIAL_TO_MODEL_PROVIDER[credentialType];
340
766
  if (!provider) {
341
- return this.envVarModelConfig();
767
+ return null;
342
768
  }
343
- const data = await this.credentialsService.decrypt(credential, true);
344
769
  const apiKey = typeof data.apiKey === 'string' ? data.apiKey : '';
345
- const urlField = URL_FIELD_MAP[credential.type];
770
+ const urlField = URL_FIELD_MAP[credentialType];
346
771
  const rawUrl = urlField ? data[urlField] : undefined;
347
772
  const baseUrl = typeof rawUrl === 'string' ? rawUrl : '';
348
- const modelName = prefs.modelName ?? this.extractModelName(this.config.model);
349
773
  const id = `${provider}/${modelName}`;
350
- if (baseUrl) {
351
- return { id, url: baseUrl, ...(apiKey ? { apiKey } : {}) };
352
- }
353
- if (apiKey) {
354
- return { id, url: '', apiKey };
355
- }
356
- return id;
774
+ if (!baseUrl && !apiKey)
775
+ return null;
776
+ const headers = modelCredentialHeaders(credentialType, data);
777
+ return { id, url: baseUrl, ...(apiKey ? { apiKey } : {}), ...(headers ? { headers } : {}) };
357
778
  }
358
779
  deploymentLabel() {
359
780
  if (this.isCloud)
@@ -369,23 +790,24 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
369
790
  throw new unprocessable_error_1.UnprocessableRequestError(`Cannot update ${label}-managed fields: ${present.join(', ')}`);
370
791
  }
371
792
  }
372
- validateAdminSettingsUpdate(update) {
373
- const c = this.config;
793
+ validateAdminSettingsUpdate(update, current, sandboxProviderOverride) {
374
794
  const touchesSandboxSettings = update.sandboxEnabled !== undefined ||
375
795
  update.sandboxProvider !== undefined ||
376
796
  update.sandboxImage !== undefined ||
377
797
  update.sandboxTimeout !== undefined ||
378
798
  update.daytonaCredentialId !== undefined ||
379
- update.n8nSandboxCredentialId !== undefined;
380
- if (!touchesSandboxSettings) {
799
+ update.n8nSandboxCredentialId !== undefined ||
800
+ update.sandboxConnection !== undefined;
801
+ if (!touchesSandboxSettings)
381
802
  return;
382
- }
383
- const sandboxProvider = update.sandboxProvider ?? (0, sandbox_provider_1.normalizeSandboxProvider)(c.sandboxProvider);
384
- const sandboxEnabled = update.sandboxEnabled ?? c.sandboxEnabled;
803
+ const sandboxProvider = (0, sandbox_provider_1.normalizeSandboxProvider)(sandboxProviderOverride ??
804
+ update.sandboxProvider ??
805
+ current.sandboxProvider ??
806
+ this.environmentSandboxProvider);
807
+ const sandboxEnabled = update.sandboxEnabled ?? current.sandboxEnabled ?? false;
385
808
  const unavailableReason = this.getSandboxUnavailableReason(sandboxEnabled, sandboxProvider);
386
- if (unavailableReason) {
809
+ if (unavailableReason)
387
810
  throw new unprocessable_error_1.UnprocessableRequestError(unavailableReason);
388
- }
389
811
  }
390
812
  getSandboxUnavailableReason(sandboxEnabled, sandboxProvider) {
391
813
  if (sandboxEnabled &&
@@ -431,18 +853,20 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
431
853
  this.mcpAccessEnabled = persisted.mcpAccessEnabled;
432
854
  if (persisted.sandboxEnabled !== undefined)
433
855
  c.sandboxEnabled = persisted.sandboxEnabled;
434
- if (persisted.sandboxProvider !== undefined)
435
- c.sandboxProvider = (0, sandbox_provider_1.normalizeSandboxProvider)(persisted.sandboxProvider);
856
+ const isProxyEnabled = this.aiService.isProxyEnabled();
857
+ this.sandboxProviderOverride =
858
+ this.isCloud || isProxyEnabled || !persisted.sandboxProvider
859
+ ? undefined
860
+ : (0, sandbox_provider_1.normalizeSandboxProvider)(persisted.sandboxProvider);
861
+ c.sandboxProvider = isProxyEnabled
862
+ ? 'daytona'
863
+ : (this.sandboxProviderOverride ?? this.environmentSandboxProvider);
436
864
  if (persisted.sandboxImage !== undefined)
437
865
  c.sandboxImage = persisted.sandboxImage;
438
866
  if (persisted.sandboxTimeout !== undefined)
439
867
  c.sandboxTimeout = persisted.sandboxTimeout;
440
- if (persisted.daytonaCredentialId !== undefined)
441
- this.adminDaytonaCredentialId = persisted.daytonaCredentialId;
442
- if (persisted.n8nSandboxCredentialId !== undefined)
443
- this.adminN8nSandboxCredentialId = persisted.n8nSandboxCredentialId;
444
- if (persisted.searchCredentialId !== undefined)
445
- this.adminSearchCredentialId = persisted.searchCredentialId;
868
+ if (persisted.modelName !== undefined)
869
+ this.adminModelName = persisted.modelName;
446
870
  if (persisted.localGatewayDisabled !== undefined)
447
871
  c.localGatewayDisabled = persisted.localGatewayDisabled;
448
872
  if (persisted.browserUseEnabled !== undefined)
@@ -451,36 +875,88 @@ let InstanceAiSettingsService = InstanceAiSettingsService_1 = class InstanceAiSe
451
875
  readUserPreferences(user) {
452
876
  return user.settings?.instanceAi ?? {};
453
877
  }
454
- async persistAdminSettings() {
878
+ snapshotAdminSettings() {
455
879
  const c = this.config;
456
- const value = {
880
+ return {
457
881
  enabled: this.enabled,
458
882
  permissions: this.permissions,
459
883
  mcpServers: c.mcpServers,
460
884
  mcpAccessEnabled: this.mcpAccessEnabled,
461
885
  sandboxEnabled: c.sandboxEnabled,
462
- sandboxProvider: c.sandboxProvider,
886
+ ...(this.sandboxProviderOverride ? { sandboxProvider: this.sandboxProviderOverride } : {}),
463
887
  sandboxImage: c.sandboxImage,
464
888
  sandboxTimeout: c.sandboxTimeout,
465
- daytonaCredentialId: this.adminDaytonaCredentialId,
466
- n8nSandboxCredentialId: this.adminN8nSandboxCredentialId,
467
- searchCredentialId: this.adminSearchCredentialId,
889
+ modelName: this.adminModelName,
468
890
  localGatewayDisabled: c.localGatewayDisabled,
469
891
  browserUseEnabled: c.browserUseEnabled,
470
892
  };
471
- await this.settingsRepository.upsert({ key: ADMIN_SETTINGS_KEY, value: JSON.stringify(value), loadOnStartup: true }, ['key']);
893
+ }
894
+ mergeAdminSettings(base, update) {
895
+ return {
896
+ ...base,
897
+ ...update,
898
+ permissions: update.permissions
899
+ ? { ...(base.permissions ?? api_types_1.DEFAULT_INSTANCE_AI_PERMISSIONS), ...update.permissions }
900
+ : base.permissions,
901
+ };
902
+ }
903
+ async readPersistedAdminSettings() {
904
+ const row = await this.settingsRepository.findByKey(ADMIN_SETTINGS_KEY);
905
+ return this.parsePersistedAdminSettings(row?.value);
906
+ }
907
+ async withPersistedAdminSettings(read) {
908
+ return await this.dbLockService.withLockContext(1007, async (ctx) => {
909
+ const row = await this.settingsRepository.findByKeyInContext(ADMIN_SETTINGS_KEY, ctx);
910
+ return await read(ctx, this.parsePersistedAdminSettings(row?.value));
911
+ });
912
+ }
913
+ async readAdminModelSelection() {
914
+ return await this.withPersistedAdminSettings(async (ctx, persisted) => ({
915
+ modelCredentialId: await this.instanceCredentialBroker.getAssignedCredentialId(exports.INSTANCE_AI_MODEL_CREDENTIAL_POLICY, ctx),
916
+ modelName: persisted.modelName ?? null,
917
+ }));
918
+ }
919
+ parsePersistedAdminSettings(value) {
920
+ if (value === undefined)
921
+ return {};
922
+ const settings = (0, n8n_workflow_1.jsonParse)(value, { fallbackValue: {} });
923
+ delete settings.modelCredentialId;
924
+ delete settings.daytonaCredentialId;
925
+ delete settings.n8nSandboxCredentialId;
926
+ delete settings.searchCredentialId;
927
+ return settings;
928
+ }
929
+ emitSettingsUpdated(previous, current) {
930
+ try {
931
+ this.eventService.emit('instance-ai-settings-updated', {
932
+ mcpSettingsChanged: current.mcpServers !== previous.mcpServers ||
933
+ current.mcpAccessEnabled !== previous.mcpAccessEnabled,
934
+ });
935
+ }
936
+ catch (error) {
937
+ di_1.Container.get(backend_common_1.Logger)
938
+ .scoped('instance-ai')
939
+ .warn('Failed to apply local settings event', {
940
+ error: (0, ensure_error_1.ensureError)(error).message,
941
+ });
942
+ }
472
943
  }
473
944
  };
474
945
  exports.InstanceAiSettingsService = InstanceAiSettingsService;
475
946
  InstanceAiSettingsService.MANAGED_ADMIN_FIELDS = [
476
947
  'mcpServers',
477
948
  'sandboxEnabled',
478
- 'sandboxProvider',
479
949
  'sandboxImage',
480
950
  'sandboxTimeout',
951
+ ];
952
+ InstanceAiSettingsService.INSTANCE_CREDENTIAL_FIELDS = [
953
+ 'modelCredentialId',
481
954
  'daytonaCredentialId',
482
955
  'n8nSandboxCredentialId',
483
956
  'searchCredentialId',
957
+ 'modelConnection',
958
+ 'sandboxConnection',
959
+ 'searchConnection',
484
960
  ];
485
961
  InstanceAiSettingsService.MANAGED_PREFERENCE_FIELDS = [
486
962
  'credentialId',
@@ -488,6 +964,6 @@ InstanceAiSettingsService.MANAGED_PREFERENCE_FIELDS = [
488
964
  ];
489
965
  exports.InstanceAiSettingsService = InstanceAiSettingsService = InstanceAiSettingsService_1 = __decorate([
490
966
  (0, di_1.Service)(),
491
- __metadata("design:paramtypes", [config_1.GlobalConfig, db_1.SettingsRepository, db_1.UserRepository, user_service_1.UserService, ai_service_1.AiService, credentials_service_1.CredentialsService, credentials_finder_service_1.CredentialsFinderService, event_service_1.EventService])
967
+ __metadata("design:paramtypes", [config_1.GlobalConfig, db_1.DbLockService, db_1.SettingsRepository, db_1.UserRepository, user_service_1.UserService, ai_service_1.AiService, credentials_service_1.CredentialsService, credentials_finder_service_1.CredentialsFinderService, instance_credential_broker_1.InstanceCredentialBroker, event_service_1.EventService])
492
968
  ], InstanceAiSettingsService);
493
969
  //# sourceMappingURL=instance-ai-settings.service.js.map