n8n 2.22.3 → 2.23.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 (628) hide show
  1. package/dist/auth/auth.service.d.ts +2 -0
  2. package/dist/auth/auth.service.js +15 -4
  3. package/dist/auth/auth.service.js.map +1 -1
  4. package/dist/build.tsbuildinfo +1 -1
  5. package/dist/chat/chat-service.types.d.ts +4 -4
  6. package/dist/commands/execute.d.ts +2 -2
  7. package/dist/commands/export/workflow.js +1 -0
  8. package/dist/commands/export/workflow.js.map +1 -1
  9. package/dist/commands/license/info.js +4 -4
  10. package/dist/commands/license/info.js.map +1 -1
  11. package/dist/commands/start.js +21 -1
  12. package/dist/commands/start.js.map +1 -1
  13. package/dist/constants.js +1 -0
  14. package/dist/constants.js.map +1 -1
  15. package/dist/controllers/annotation-tags.controller.ee.d.ts +1 -1
  16. package/dist/controllers/e2e.controller.js +1 -0
  17. package/dist/controllers/e2e.controller.js.map +1 -1
  18. package/dist/controllers/oauth/oauth1-credential.controller.d.ts +1 -1
  19. package/dist/controllers/oauth/oauth1-credential.controller.js +4 -7
  20. package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
  21. package/dist/controllers/oauth/oauth2-credential.controller.js +3 -6
  22. package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
  23. package/dist/controllers/redaction-enforcement-mapper.d.ts +3 -0
  24. package/dist/controllers/redaction-enforcement-mapper.js +27 -0
  25. package/dist/controllers/redaction-enforcement-mapper.js.map +1 -0
  26. package/dist/controllers/security-settings.controller.d.ts +8 -2
  27. package/dist/controllers/security-settings.controller.js +35 -25
  28. package/dist/controllers/security-settings.controller.js.map +1 -1
  29. package/dist/credentials/credential-connection-status-provider.interface.d.ts +3 -0
  30. package/dist/credentials/credential-connection-status-provider.interface.js +3 -0
  31. package/dist/credentials/credential-connection-status-provider.interface.js.map +1 -0
  32. package/dist/credentials/credential-connection-status-proxy.d.ts +6 -0
  33. package/dist/credentials/credential-connection-status-proxy.js +25 -0
  34. package/dist/credentials/credential-connection-status-proxy.js.map +1 -0
  35. package/dist/credentials/credential-resolution-provider.interface.d.ts +1 -0
  36. package/dist/credentials/credentials.controller.d.ts +2 -0
  37. package/dist/credentials/credentials.service.d.ts +10 -1
  38. package/dist/credentials/credentials.service.ee.d.ts +2 -0
  39. package/dist/credentials/credentials.service.ee.js +13 -3
  40. package/dist/credentials/credentials.service.ee.js.map +1 -1
  41. package/dist/credentials/credentials.service.js +34 -7
  42. package/dist/credentials/credentials.service.js.map +1 -1
  43. package/dist/credentials/dynamic-credentials-proxy.d.ts +2 -0
  44. package/dist/credentials/dynamic-credentials-proxy.js +9 -0
  45. package/dist/credentials/dynamic-credentials-proxy.js.map +1 -1
  46. package/dist/credentials-helper.js +2 -1
  47. package/dist/credentials-helper.js.map +1 -1
  48. package/dist/errors/feature-not-licensed.error.d.ts +3 -1
  49. package/dist/errors/feature-not-licensed.error.js +2 -2
  50. package/dist/errors/feature-not-licensed.error.js.map +1 -1
  51. package/dist/evaluation.ee/evaluation-collection.service.js +2 -0
  52. package/dist/evaluation.ee/evaluation-collection.service.js.map +1 -1
  53. package/dist/evaluation.ee/insights/eval-insights.controller.ee.d.ts +41 -0
  54. package/dist/evaluation.ee/insights/eval-insights.controller.ee.js +62 -0
  55. package/dist/evaluation.ee/insights/eval-insights.controller.ee.js.map +1 -0
  56. package/dist/evaluation.ee/insights/eval-insights.service.d.ts +25 -0
  57. package/dist/evaluation.ee/insights/eval-insights.service.js +206 -0
  58. package/dist/evaluation.ee/insights/eval-insights.service.js.map +1 -0
  59. package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +3 -2
  60. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +16 -2
  61. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
  62. package/dist/events/relays/telemetry.event-relay.d.ts +3 -1
  63. package/dist/events/relays/telemetry.event-relay.js +9 -3
  64. package/dist/events/relays/telemetry.event-relay.js.map +1 -1
  65. package/dist/execution-lifecycle/execution-lifecycle-hooks.d.ts +1 -1
  66. package/dist/execution-lifecycle/execution-lifecycle-hooks.js +4 -2
  67. package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
  68. package/dist/executions/execution-data/db-store.d.ts +4 -2
  69. package/dist/executions/execution-data/db-store.js +9 -4
  70. package/dist/executions/execution-data/db-store.js.map +1 -1
  71. package/dist/executions/execution-data/missing-execution-data.error.d.ts +5 -0
  72. package/dist/executions/execution-data/missing-execution-data.error.js +11 -0
  73. package/dist/executions/execution-data/missing-execution-data.error.js.map +1 -0
  74. package/dist/executions/execution-data/types.d.ts +3 -2
  75. package/dist/executions/execution-data/types.js.map +1 -1
  76. package/dist/executions/execution-persistence.d.ts +12 -3
  77. package/dist/executions/execution-persistence.js +102 -26
  78. package/dist/executions/execution-persistence.js.map +1 -1
  79. package/dist/external-hooks.d.ts +6 -1
  80. package/dist/external-hooks.js.map +1 -1
  81. package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.d.ts +3 -2
  82. package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js +17 -12
  83. package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js.map +1 -1
  84. package/dist/interfaces.d.ts +1 -0
  85. package/dist/license.d.ts +2 -0
  86. package/dist/license.js +6 -0
  87. package/dist/license.js.map +1 -1
  88. package/dist/load-nodes-and-credentials.d.ts +32 -6
  89. package/dist/load-nodes-and-credentials.js +8 -79
  90. package/dist/load-nodes-and-credentials.js.map +1 -1
  91. package/dist/manual-execution.service.js +3 -0
  92. package/dist/manual-execution.service.js.map +1 -1
  93. package/dist/modules/agents/agent-execution.service.js +5 -5
  94. package/dist/modules/agents/agent-execution.service.js.map +1 -1
  95. package/dist/modules/agents/agent-sse-stream.js +17 -1
  96. package/dist/modules/agents/agent-sse-stream.js.map +1 -1
  97. package/dist/modules/agents/agents-tools.service.js +7 -5
  98. package/dist/modules/agents/agents-tools.service.js.map +1 -1
  99. package/dist/modules/agents/agents.controller.d.ts +29 -3
  100. package/dist/modules/agents/agents.controller.js +88 -7
  101. package/dist/modules/agents/agents.controller.js.map +1 -1
  102. package/dist/modules/agents/agents.module.d.ts +1 -1
  103. package/dist/modules/agents/agents.module.js +12 -6
  104. package/dist/modules/agents/agents.module.js.map +1 -1
  105. package/dist/modules/agents/agents.service.d.ts +7 -8
  106. package/dist/modules/agents/agents.service.js +120 -65
  107. package/dist/modules/agents/agents.service.js.map +1 -1
  108. package/dist/modules/agents/builder/agents-builder-model-recommendations.d.ts +1 -1
  109. package/dist/modules/agents/builder/agents-builder-model-recommendations.js +3 -3
  110. package/dist/modules/agents/builder/agents-builder-model-recommendations.js.map +1 -1
  111. package/dist/modules/agents/builder/agents-builder-prompts.d.ts +9 -17
  112. package/dist/modules/agents/builder/agents-builder-prompts.js +145 -549
  113. package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
  114. package/dist/modules/agents/builder/agents-builder-settings.service.js +2 -2
  115. package/dist/modules/agents/builder/agents-builder-settings.service.js.map +1 -1
  116. package/dist/modules/agents/builder/agents-builder-tools.service.js +10 -10
  117. package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
  118. package/dist/modules/agents/builder/agents-builder.service.d.ts +3 -1
  119. package/dist/modules/agents/builder/agents-builder.service.js +58 -9
  120. package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
  121. package/dist/modules/agents/builder/interactive/ask-credential.tool.js +2 -2
  122. package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
  123. package/dist/modules/agents/builder/interactive/ask-llm.tool.js +2 -2
  124. package/dist/modules/agents/builder/interactive/ask-llm.tool.js.map +1 -1
  125. package/dist/modules/agents/builder/interactive/ask-question.tool.js +2 -2
  126. package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -1
  127. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +2 -2
  128. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -1
  129. package/dist/modules/agents/builder/prompts/config-mutation.prompt.d.ts +1 -0
  130. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +132 -0
  131. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -0
  132. package/dist/modules/agents/builder/prompts/config-rules.prompt.d.ts +2 -0
  133. package/dist/modules/agents/builder/prompts/config-rules.prompt.js +63 -0
  134. package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -0
  135. package/dist/modules/agents/builder/prompts/llm-selection.prompt.d.ts +1 -0
  136. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +47 -0
  137. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js.map +1 -0
  138. package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -0
  139. package/dist/modules/agents/builder/prompts/memory.prompt.js +60 -0
  140. package/dist/modules/agents/builder/prompts/memory.prompt.js.map +1 -0
  141. package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -0
  142. package/dist/modules/agents/builder/prompts/tools.prompt.js +81 -0
  143. package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -0
  144. package/dist/modules/agents/builder/skills/index.d.ts +2 -0
  145. package/dist/modules/agents/builder/skills/index.js +12 -0
  146. package/dist/modules/agents/builder/skills/index.js.map +1 -0
  147. package/dist/modules/agents/builder/skills/integrations.skill.d.ts +2 -0
  148. package/dist/modules/agents/builder/skills/integrations.skill.js +53 -0
  149. package/dist/modules/agents/builder/skills/integrations.skill.js.map +1 -0
  150. package/dist/modules/agents/builder/skills/research.skill.d.ts +2 -0
  151. package/dist/modules/agents/builder/skills/research.skill.js +42 -0
  152. package/dist/modules/agents/builder/skills/research.skill.js.map +1 -0
  153. package/dist/modules/agents/builder/skills/target-skills.skill.d.ts +2 -0
  154. package/dist/modules/agents/builder/skills/target-skills.skill.js +59 -0
  155. package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -0
  156. package/dist/modules/agents/entities/{agent-published-version.entity.d.ts → agent-history.entity.d.ts} +4 -7
  157. package/dist/modules/agents/entities/{agent-published-version.entity.js → agent-history.entity.js} +22 -34
  158. package/dist/modules/agents/entities/agent-history.entity.js.map +1 -0
  159. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.d.ts +7 -0
  160. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js +38 -0
  161. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js.map +1 -0
  162. package/dist/modules/agents/entities/agent-memory-entry-lock.entity.d.ts +7 -0
  163. package/dist/modules/{instance-ai/entities/instance-ai-workflow-snapshot.entity.js → agents/entities/agent-memory-entry-lock.entity.js} +16 -19
  164. package/dist/modules/agents/entities/agent-memory-entry-lock.entity.js.map +1 -0
  165. package/dist/modules/agents/entities/agent-memory-entry-source.entity.d.ts +9 -0
  166. package/dist/modules/agents/entities/agent-memory-entry-source.entity.js +49 -0
  167. package/dist/modules/agents/entities/agent-memory-entry-source.entity.js.map +1 -0
  168. package/dist/modules/agents/entities/agent-memory-entry.entity.d.ts +15 -0
  169. package/dist/modules/agents/entities/agent-memory-entry.entity.js +65 -0
  170. package/dist/modules/agents/entities/agent-memory-entry.entity.js.map +1 -0
  171. package/dist/modules/agents/entities/agent-observation-cursor.entity.d.ts +2 -3
  172. package/dist/modules/agents/entities/agent-observation-cursor.entity.js +5 -4
  173. package/dist/modules/agents/entities/agent-observation-cursor.entity.js.map +1 -1
  174. package/dist/modules/agents/entities/agent-observation-lock.entity.d.ts +2 -3
  175. package/dist/modules/agents/entities/agent-observation-lock.entity.js +5 -4
  176. package/dist/modules/agents/entities/agent-observation-lock.entity.js.map +1 -1
  177. package/dist/modules/agents/entities/agent-observation.entity.d.ts +2 -3
  178. package/dist/modules/agents/entities/agent-observation.entity.js +6 -5
  179. package/dist/modules/agents/entities/agent-observation.entity.js.map +1 -1
  180. package/dist/modules/agents/entities/agent.entity.d.ts +3 -5
  181. package/dist/modules/agents/entities/agent.entity.js +7 -14
  182. package/dist/modules/agents/entities/agent.entity.js.map +1 -1
  183. package/dist/modules/agents/episodic-memory.d.ts +2 -0
  184. package/dist/modules/agents/episodic-memory.js +12 -0
  185. package/dist/modules/agents/episodic-memory.js.map +1 -0
  186. package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +2 -1
  187. package/dist/modules/agents/integrations/agent-chat-bridge.js +19 -5
  188. package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
  189. package/dist/modules/agents/integrations/agent-schedule.service.js +10 -6
  190. package/dist/modules/agents/integrations/agent-schedule.service.js.map +1 -1
  191. package/dist/modules/agents/integrations/chat-integration.service.js +1 -1
  192. package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -1
  193. package/dist/modules/agents/integrations/n8n-memory.d.ts +41 -18
  194. package/dist/modules/agents/integrations/n8n-memory.js +519 -77
  195. package/dist/modules/agents/integrations/n8n-memory.js.map +1 -1
  196. package/dist/modules/agents/integrations/platforms/slack-integration.js +2 -12
  197. package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
  198. package/dist/modules/agents/integrations/rich-interaction-tool.d.ts +1 -1
  199. package/dist/modules/agents/integrations/rich-interaction-tool.js +2 -2
  200. package/dist/modules/agents/integrations/rich-interaction-tool.js.map +1 -1
  201. package/dist/modules/agents/integrations/slack-app-setup.service.d.ts +52 -0
  202. package/dist/modules/agents/integrations/slack-app-setup.service.js +316 -0
  203. package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -0
  204. package/dist/modules/agents/json-config/from-json-config.d.ts +2 -3
  205. package/dist/modules/agents/json-config/from-json-config.js +76 -61
  206. package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
  207. package/dist/modules/agents/json-config/schema-text-serializer.js +2 -1
  208. package/dist/modules/agents/json-config/schema-text-serializer.js.map +1 -1
  209. package/dist/modules/agents/repositories/agent-history.repository.d.ts +19 -0
  210. package/dist/modules/agents/repositories/agent-history.repository.js +51 -0
  211. package/dist/modules/agents/repositories/agent-history.repository.js.map +1 -0
  212. package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.d.ts +5 -0
  213. package/dist/modules/{instance-ai/repositories/instance-ai-workflow-snapshot.repository.js → agents/repositories/agent-memory-entry-cursor.repository.js} +8 -8
  214. package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.js.map +1 -0
  215. package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.d.ts +5 -0
  216. package/dist/modules/{instance-ai/repositories/instance-ai-observational-memory.repository.js → agents/repositories/agent-memory-entry-lock.repository.js} +8 -8
  217. package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.js.map +1 -0
  218. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.d.ts +5 -0
  219. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js +26 -0
  220. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js.map +1 -0
  221. package/dist/modules/agents/repositories/agent-memory-entry.repository.d.ts +5 -0
  222. package/dist/modules/agents/repositories/agent-memory-entry.repository.js +26 -0
  223. package/dist/modules/agents/repositories/agent-memory-entry.repository.js.map +1 -0
  224. package/dist/modules/agents/repositories/agent.repository.js +3 -3
  225. package/dist/modules/agents/repositories/agent.repository.js.map +1 -1
  226. package/dist/modules/agents/runtime/agent-secure-runtime.js +5 -5
  227. package/dist/modules/agents/runtime/agent-secure-runtime.js.map +1 -1
  228. package/dist/modules/agents/tools/environment-tool.d.ts +1 -1
  229. package/dist/modules/agents/tools/environment-tool.js +3 -3
  230. package/dist/modules/agents/tools/environment-tool.js.map +1 -1
  231. package/dist/modules/agents/tools/node-tool-factory.js +5 -5
  232. package/dist/modules/agents/tools/node-tool-factory.js.map +1 -1
  233. package/dist/modules/agents/tools/workflow-tool-factory.js +3 -3
  234. package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -1
  235. package/dist/modules/agents/tracing/builder-telemetry.d.ts +2 -3
  236. package/dist/modules/agents/tracing/builder-telemetry.js +36 -3
  237. package/dist/modules/agents/tracing/builder-telemetry.js.map +1 -1
  238. package/dist/modules/agents/utils/agent-draft.utils.js +1 -2
  239. package/dist/modules/agents/utils/agent-draft.utils.js.map +1 -1
  240. package/dist/modules/agents/utils/agent-memory-scope.d.ts +3 -0
  241. package/dist/modules/agents/utils/agent-memory-scope.js +15 -0
  242. package/dist/modules/agents/utils/agent-memory-scope.js.map +1 -0
  243. package/dist/modules/chat-hub/chat-hub.constants.js +4 -0
  244. package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
  245. package/dist/modules/chat-hub/context-limits.js +1 -0
  246. package/dist/modules/chat-hub/context-limits.js.map +1 -1
  247. package/dist/modules/dynamic-credentials.ee/constants.d.ts +3 -0
  248. package/dist/modules/dynamic-credentials.ee/constants.js +7 -0
  249. package/dist/modules/dynamic-credentials.ee/constants.js.map +1 -0
  250. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js +14 -2
  251. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js.map +1 -1
  252. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.d.ts +2 -2
  253. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js +18 -4
  254. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js.map +1 -1
  255. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.d.ts +1 -1
  256. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js +4 -1
  257. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js.map +1 -1
  258. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.d.ts +4 -0
  259. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js +11 -0
  260. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js.map +1 -0
  261. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.d.ts +7 -0
  262. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js +40 -0
  263. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js.map +1 -0
  264. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.d.ts +3 -1
  265. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js +6 -3
  266. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -1
  267. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.d.ts +2 -0
  268. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js +22 -0
  269. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js.map +1 -1
  270. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.d.ts +3 -1
  271. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +7 -3
  272. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -1
  273. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.d.ts +4 -1
  274. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js +11 -3
  275. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -1
  276. package/dist/modules/dynamic-credentials.ee/services/index.d.ts +2 -0
  277. package/dist/modules/dynamic-credentials.ee/services/index.js +2 -0
  278. package/dist/modules/dynamic-credentials.ee/services/index.js.map +1 -1
  279. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.d.ts +14 -0
  280. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js +70 -0
  281. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js.map +1 -0
  282. package/dist/modules/insights/insights-collection.service.js +1 -1
  283. package/dist/modules/insights/insights-collection.service.js.map +1 -1
  284. package/dist/modules/instance-ai/entities/index.d.ts +6 -2
  285. package/dist/modules/instance-ai/entities/index.js +9 -5
  286. package/dist/modules/instance-ai/entities/index.js.map +1 -1
  287. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.d.ts +12 -0
  288. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js +54 -0
  289. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js.map +1 -0
  290. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.d.ts +6 -0
  291. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js +33 -0
  292. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js.map +1 -0
  293. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.d.ts +8 -0
  294. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js +37 -0
  295. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js.map +1 -0
  296. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.d.ts +12 -0
  297. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js +52 -0
  298. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js.map +1 -0
  299. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.d.ts +19 -0
  300. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js +82 -0
  301. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js.map +1 -0
  302. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.d.ts +2 -0
  303. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js +8 -0
  304. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js.map +1 -1
  305. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.d.ts +12 -2
  306. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js +40 -4
  307. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js.map +1 -1
  308. package/dist/modules/instance-ai/eval/execution.service.d.ts +8 -2
  309. package/dist/modules/instance-ai/eval/execution.service.js +137 -47
  310. package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
  311. package/dist/modules/instance-ai/eval/llm-wire-server.d.ts +31 -0
  312. package/dist/modules/instance-ai/eval/llm-wire-server.js +127 -0
  313. package/dist/modules/instance-ai/eval/llm-wire-server.js.map +1 -0
  314. package/dist/modules/instance-ai/eval/openai-envelope.d.ts +6 -0
  315. package/dist/modules/instance-ai/eval/openai-envelope.js +96 -0
  316. package/dist/modules/instance-ai/eval/openai-envelope.js.map +1 -0
  317. package/dist/modules/instance-ai/eval/proxy-loopback.d.ts +1 -0
  318. package/dist/modules/instance-ai/eval/proxy-loopback.js +44 -0
  319. package/dist/modules/instance-ai/eval/proxy-loopback.js.map +1 -0
  320. package/dist/modules/instance-ai/eval/sub-agent-eval.service.js +29 -7
  321. package/dist/modules/instance-ai/eval/sub-agent-eval.service.js.map +1 -1
  322. package/dist/modules/instance-ai/eval/workflow-analysis.d.ts +7 -1
  323. package/dist/modules/instance-ai/eval/workflow-analysis.js +178 -3
  324. package/dist/modules/instance-ai/eval/workflow-analysis.js.map +1 -1
  325. package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +6 -6
  326. package/dist/modules/instance-ai/instance-ai-memory.service.js +44 -85
  327. package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
  328. package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +2 -1
  329. package/dist/modules/instance-ai/instance-ai-settings.service.js +11 -22
  330. package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
  331. package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +2 -0
  332. package/dist/modules/instance-ai/instance-ai.adapter.service.js +105 -13
  333. package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
  334. package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -1
  335. package/dist/modules/instance-ai/instance-ai.module.js +10 -6
  336. package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
  337. package/dist/modules/instance-ai/instance-ai.service.d.ts +34 -12
  338. package/dist/modules/instance-ai/instance-ai.service.js +724 -264
  339. package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
  340. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +4 -1
  341. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +3 -1
  342. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -1
  343. package/dist/modules/instance-ai/message-parser.d.ts +3 -3
  344. package/dist/modules/instance-ai/message-parser.js +65 -61
  345. package/dist/modules/instance-ai/message-parser.js.map +1 -1
  346. package/dist/modules/instance-ai/node-definition-resolver.js +12 -48
  347. package/dist/modules/instance-ai/node-definition-resolver.js.map +1 -1
  348. package/dist/modules/instance-ai/repositories/index.d.ts +4 -2
  349. package/dist/modules/instance-ai/repositories/index.js +9 -5
  350. package/dist/modules/instance-ai/repositories/index.js.map +1 -1
  351. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.d.ts +5 -0
  352. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js +26 -0
  353. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js.map +1 -0
  354. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.d.ts +5 -0
  355. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js +26 -0
  356. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js.map +1 -0
  357. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.d.ts +5 -0
  358. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js +26 -0
  359. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js.map +1 -0
  360. package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.d.ts +5 -0
  361. package/dist/modules/{agents/repositories/agent-published-version.repository.js → instance-ai/repositories/instance-ai-observation.repository.js} +8 -17
  362. package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.js.map +1 -0
  363. package/dist/modules/instance-ai/storage/db-snapshot-storage.d.ts +2 -0
  364. package/dist/modules/instance-ai/storage/db-snapshot-storage.js +12 -2
  365. package/dist/modules/instance-ai/storage/db-snapshot-storage.js.map +1 -1
  366. package/dist/modules/instance-ai/storage/index.d.ts +2 -3
  367. package/dist/modules/instance-ai/storage/index.js +5 -7
  368. package/dist/modules/instance-ai/storage/index.js.map +1 -1
  369. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.d.ts +15 -0
  370. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js +94 -0
  371. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js.map +1 -0
  372. package/dist/modules/instance-ai/storage/typeorm-agent-memory.d.ts +94 -0
  373. package/dist/modules/instance-ai/storage/typeorm-agent-memory.js +324 -0
  374. package/dist/modules/instance-ai/storage/typeorm-agent-memory.js.map +1 -0
  375. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.d.ts +37 -0
  376. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js +212 -0
  377. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js.map +1 -0
  378. package/dist/modules/instance-ai/web-research/fetch-and-extract.js +34 -11
  379. package/dist/modules/instance-ai/web-research/fetch-and-extract.js.map +1 -1
  380. package/dist/modules/mcp/mcp.service.js +5 -5
  381. package/dist/modules/mcp/mcp.service.js.map +1 -1
  382. package/dist/modules/mcp/tools/schemas.d.ts +24 -24
  383. package/dist/modules/mcp/tools/search-projects.tool.js +59 -13
  384. package/dist/modules/mcp/tools/search-projects.tool.js.map +1 -1
  385. package/dist/modules/mcp/tools/test-workflow.tool.d.ts +2 -2
  386. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.d.ts +35 -0
  387. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js +88 -0
  388. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js.map +1 -0
  389. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.d.ts +3 -2
  390. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +41 -9
  391. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
  392. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.d.ts +13 -0
  393. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js +87 -0
  394. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js.map +1 -0
  395. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +2 -1
  396. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +42 -6
  397. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
  398. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.d.ts +2 -1
  399. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +5 -1
  400. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
  401. package/dist/modules/mcp/tools/workflow-validation.utils.js +1 -1
  402. package/dist/modules/mcp/tools/workflow-validation.utils.js.map +1 -1
  403. package/dist/modules/mcp-registry/mcp-registry-test.controller.js +5 -1
  404. package/dist/modules/mcp-registry/mcp-registry-test.controller.js.map +1 -1
  405. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.d.ts +18 -0
  406. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js +73 -0
  407. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js.map +1 -0
  408. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.d.ts +5 -0
  409. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js +31 -0
  410. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js.map +1 -0
  411. package/dist/modules/n8n-packages/io/package-writer.d.ts +6 -0
  412. package/dist/{scaling/multi-main-setup.types.js → modules/n8n-packages/io/package-writer.js} +1 -1
  413. package/dist/modules/n8n-packages/io/package-writer.js.map +1 -0
  414. package/dist/modules/n8n-packages/io/slug.utils.d.ts +1 -0
  415. package/dist/modules/n8n-packages/io/slug.utils.js +16 -0
  416. package/dist/modules/n8n-packages/io/slug.utils.js.map +1 -0
  417. package/dist/modules/n8n-packages/io/tar/tar-package-writer.d.ts +9 -0
  418. package/dist/modules/n8n-packages/io/tar/tar-package-writer.js +71 -0
  419. package/dist/modules/n8n-packages/io/tar/tar-package-writer.js.map +1 -0
  420. package/dist/modules/n8n-packages/n8n-packages.controller.d.ts +10 -0
  421. package/dist/modules/n8n-packages/n8n-packages.controller.js +45 -0
  422. package/dist/modules/n8n-packages/n8n-packages.controller.js.map +1 -0
  423. package/dist/modules/{inbound-secrets/inbound-secrets.module.d.ts → n8n-packages/n8n-packages.module.d.ts} +1 -1
  424. package/dist/modules/{inbound-secrets/inbound-secrets.module.js → n8n-packages/n8n-packages.module.js} +12 -16
  425. package/dist/modules/n8n-packages/n8n-packages.module.js.map +1 -0
  426. package/dist/modules/n8n-packages/n8n-packages.service.d.ts +10 -0
  427. package/dist/modules/n8n-packages/n8n-packages.service.js +49 -0
  428. package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -0
  429. package/dist/modules/n8n-packages/n8n-packages.types.d.ts +5 -0
  430. package/dist/modules/n8n-packages/n8n-packages.types.js +3 -0
  431. package/dist/modules/n8n-packages/n8n-packages.types.js.map +1 -0
  432. package/dist/modules/n8n-packages/spec/constants.d.ts +1 -0
  433. package/dist/modules/n8n-packages/spec/constants.js +5 -0
  434. package/dist/modules/n8n-packages/spec/constants.js.map +1 -0
  435. package/dist/modules/n8n-packages/spec/manifest.schema.d.ts +55 -0
  436. package/dist/modules/n8n-packages/spec/manifest.schema.js +17 -0
  437. package/dist/modules/n8n-packages/spec/manifest.schema.js.map +1 -0
  438. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.d.ts +169 -0
  439. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js +46 -0
  440. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js.map +1 -0
  441. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.d.ts +5 -1
  442. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js +18 -2
  443. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js.map +1 -1
  444. package/dist/modules/oauth-jwe/oauth-jwe.utils.js +27 -2
  445. package/dist/modules/oauth-jwe/oauth-jwe.utils.js.map +1 -1
  446. package/dist/modules/otel/execution-level-tracer.js +1 -0
  447. package/dist/modules/otel/execution-level-tracer.js.map +1 -1
  448. package/dist/modules/otel/execution-level-tracer.types.d.ts +11 -6
  449. package/dist/modules/otel/execution-level-tracer.types.js.map +1 -1
  450. package/dist/modules/otel/otel-lifecycle-handler.d.ts +5 -1
  451. package/dist/modules/otel/otel-lifecycle-handler.js +30 -2
  452. package/dist/modules/otel/otel-lifecycle-handler.js.map +1 -1
  453. package/dist/modules/otel/otel.constants.d.ts +1 -0
  454. package/dist/modules/otel/otel.constants.js +1 -0
  455. package/dist/modules/otel/otel.constants.js.map +1 -1
  456. package/dist/modules/runtime-credentials/path-traversal.js.map +1 -0
  457. package/dist/modules/runtime-credentials/runtime-credentials-access.service.d.ts +8 -0
  458. package/dist/modules/runtime-credentials/runtime-credentials-access.service.js +35 -0
  459. package/dist/modules/runtime-credentials/runtime-credentials-access.service.js.map +1 -0
  460. package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.d.ts → runtime-credentials/runtime-credentials-context-hook.d.ts} +4 -5
  461. package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.js → runtime-credentials/runtime-credentials-context-hook.js} +14 -22
  462. package/dist/modules/runtime-credentials/runtime-credentials-context-hook.js.map +1 -0
  463. package/dist/modules/runtime-credentials/runtime-credentials.config.d.ts +3 -0
  464. package/dist/modules/{inbound-secrets/inbound-secrets.config.js → runtime-credentials/runtime-credentials.config.js} +7 -7
  465. package/dist/modules/runtime-credentials/runtime-credentials.config.js.map +1 -0
  466. package/dist/modules/runtime-credentials/runtime-credentials.module.d.ts +4 -0
  467. package/dist/modules/runtime-credentials/runtime-credentials.module.js +65 -0
  468. package/dist/modules/runtime-credentials/runtime-credentials.module.js.map +1 -0
  469. package/dist/modules/runtime-credentials/runtime-credentials.schemas.d.ts +23 -0
  470. package/dist/modules/runtime-credentials/runtime-credentials.schemas.js +10 -0
  471. package/dist/modules/runtime-credentials/runtime-credentials.schemas.js.map +1 -0
  472. package/dist/modules/runtime-credentials/runtime-credentials.service.d.ts +18 -0
  473. package/dist/modules/{inbound-secrets/inbound-secrets.service.js → runtime-credentials/runtime-credentials.service.js} +31 -28
  474. package/dist/modules/runtime-credentials/runtime-credentials.service.js.map +1 -0
  475. package/dist/modules/source-control.ee/source-control-export.service.ee.d.ts +1 -1
  476. package/dist/modules/source-control.ee/source-control-export.service.ee.js +3 -1
  477. package/dist/modules/source-control.ee/source-control-export.service.ee.js.map +1 -1
  478. package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +2 -2
  479. package/dist/modules/source-control.ee/source-control-import.service.ee.js +29 -8
  480. package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
  481. package/dist/modules/source-control.ee/source-control-status.service.ee.js +4 -4
  482. package/dist/modules/source-control.ee/source-control-status.service.ee.js.map +1 -1
  483. package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +2 -2
  484. package/dist/modules/source-control.ee/source-control.service.ee.d.ts +1 -1
  485. package/dist/modules/source-control.ee/types/exportable-workflow.d.ts +2 -1
  486. package/dist/modules/sso-saml/saml.service.ee.js +5 -1
  487. package/dist/modules/sso-saml/saml.service.ee.js.map +1 -1
  488. package/dist/modules/workflow-index/workflow-dependency.controller.d.ts +1 -4
  489. package/dist/modules/workflow-index/workflow-dependency.controller.js +2 -13
  490. package/dist/modules/workflow-index/workflow-dependency.controller.js.map +1 -1
  491. package/dist/node-catalog/node-catalog.service.d.ts +1 -2
  492. package/dist/node-catalog/node-catalog.service.js +6 -10
  493. package/dist/node-catalog/node-catalog.service.js.map +1 -1
  494. package/dist/node-execution/ephemeral-node-executor.js +19 -11
  495. package/dist/node-execution/ephemeral-node-executor.js.map +1 -1
  496. package/dist/oauth/oauth-jwe-service.proxy.d.ts +12 -2
  497. package/dist/oauth/oauth-jwe-service.proxy.js +5 -0
  498. package/dist/oauth/oauth-jwe-service.proxy.js.map +1 -1
  499. package/dist/oauth/oauth.service.d.ts +6 -1
  500. package/dist/oauth/oauth.service.js +42 -4
  501. package/dist/oauth/oauth.service.js.map +1 -1
  502. package/dist/permissions.ee/check-access.d.ts +2 -2
  503. package/dist/permissions.ee/check-access.js +15 -11
  504. package/dist/permissions.ee/check-access.js.map +1 -1
  505. package/dist/posthog/index.d.ts +2 -0
  506. package/dist/posthog/index.js +28 -6
  507. package/dist/posthog/index.js.map +1 -1
  508. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.d.ts +10 -0
  509. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +42 -0
  510. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -0
  511. package/dist/public-api/v1/openapi.yml +55 -0
  512. package/dist/requests.d.ts +1 -1
  513. package/dist/scaling/constants.js +3 -0
  514. package/dist/scaling/constants.js.map +1 -1
  515. package/dist/scaling/multi-main-setup.ee.d.ts +12 -7
  516. package/dist/scaling/multi-main-setup.ee.js +125 -22
  517. package/dist/scaling/multi-main-setup.ee.js.map +1 -1
  518. package/dist/server.d.ts +1 -0
  519. package/dist/server.js +3 -4
  520. package/dist/server.js.map +1 -1
  521. package/dist/services/dynamic-node-parameters.service.d.ts +0 -1
  522. package/dist/services/dynamic-node-parameters.service.js +6 -14
  523. package/dist/services/dynamic-node-parameters.service.js.map +1 -1
  524. package/dist/services/frontend.service.js +1 -1
  525. package/dist/services/frontend.service.js.map +1 -1
  526. package/dist/services/import.service.js +3 -1
  527. package/dist/services/import.service.js.map +1 -1
  528. package/dist/services/proxy-token-manager.js +2 -13
  529. package/dist/services/proxy-token-manager.js.map +1 -1
  530. package/dist/services/runtime-credential-proxy.service.d.ts +9 -0
  531. package/dist/services/runtime-credential-proxy.service.js +29 -0
  532. package/dist/services/runtime-credential-proxy.service.js.map +1 -0
  533. package/dist/services/url.service.d.ts +1 -0
  534. package/dist/services/url.service.js +3 -0
  535. package/dist/services/url.service.js.map +1 -1
  536. package/dist/telemetry/index.d.ts +4 -1
  537. package/dist/telemetry/index.js +16 -8
  538. package/dist/telemetry/index.js.map +1 -1
  539. package/dist/utils.d.ts +2 -1
  540. package/dist/utils.js +10 -0
  541. package/dist/utils.js.map +1 -1
  542. package/dist/webhooks/live-webhooks.js +2 -2
  543. package/dist/webhooks/live-webhooks.js.map +1 -1
  544. package/dist/webhooks/webhook-helpers.js +1 -1
  545. package/dist/webhooks/webhook-helpers.js.map +1 -1
  546. package/dist/workflow-execute-additional-data.d.ts +3 -1
  547. package/dist/workflow-execute-additional-data.js +26 -3
  548. package/dist/workflow-execute-additional-data.js.map +1 -1
  549. package/dist/workflow-helpers.d.ts +3 -1
  550. package/dist/workflow-helpers.js +39 -5
  551. package/dist/workflow-helpers.js.map +1 -1
  552. package/dist/workflow-hook-context.service.d.ts +6 -0
  553. package/dist/workflow-hook-context.service.js +32 -0
  554. package/dist/workflow-hook-context.service.js.map +1 -0
  555. package/dist/workflow-runner.js +2 -1
  556. package/dist/workflow-runner.js.map +1 -1
  557. package/dist/workflows/utils.d.ts +3 -0
  558. package/dist/workflows/utils.js +19 -0
  559. package/dist/workflows/utils.js.map +1 -1
  560. package/dist/workflows/workflow-creation.service.js +4 -2
  561. package/dist/workflows/workflow-creation.service.js.map +1 -1
  562. package/dist/workflows/workflow-execution.service.d.ts +4 -3
  563. package/dist/workflows/workflow-execution.service.js +8 -3
  564. package/dist/workflows/workflow-execution.service.js.map +1 -1
  565. package/dist/workflows/workflow-finder.service.d.ts +6 -2
  566. package/dist/workflows/workflow-finder.service.js +18 -0
  567. package/dist/workflows/workflow-finder.service.js.map +1 -1
  568. package/dist/workflows/workflow-history/workflow-history.controller.d.ts +1 -1
  569. package/dist/workflows/workflow-history/workflow-history.service.d.ts +2 -1
  570. package/dist/workflows/workflow-history/workflow-history.service.js +1 -0
  571. package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
  572. package/dist/workflows/workflow-validation.service.d.ts +3 -1
  573. package/dist/workflows/workflow-validation.service.js +6 -3
  574. package/dist/workflows/workflow-validation.service.js.map +1 -1
  575. package/dist/workflows/workflow.service.d.ts +3 -3
  576. package/dist/workflows/workflow.service.js +26 -4
  577. package/dist/workflows/workflow.service.js.map +1 -1
  578. package/dist/workflows/workflows.controller.d.ts +31 -21
  579. package/dist/workflows/workflows.controller.js +6 -2
  580. package/dist/workflows/workflows.controller.js.map +1 -1
  581. package/package.json +37 -35
  582. package/dist/modules/agents/entities/agent-published-version.entity.js.map +0 -1
  583. package/dist/modules/agents/repositories/agent-published-version.repository.d.ts +0 -20
  584. package/dist/modules/agents/repositories/agent-published-version.repository.js.map +0 -1
  585. package/dist/modules/inbound-secrets/inbound-secrets-context-hook.js.map +0 -1
  586. package/dist/modules/inbound-secrets/inbound-secrets.config.d.ts +0 -3
  587. package/dist/modules/inbound-secrets/inbound-secrets.config.js.map +0 -1
  588. package/dist/modules/inbound-secrets/inbound-secrets.module.js.map +0 -1
  589. package/dist/modules/inbound-secrets/inbound-secrets.schemas.d.ts +0 -3
  590. package/dist/modules/inbound-secrets/inbound-secrets.schemas.js +0 -6
  591. package/dist/modules/inbound-secrets/inbound-secrets.schemas.js.map +0 -1
  592. package/dist/modules/inbound-secrets/inbound-secrets.service.d.ts +0 -17
  593. package/dist/modules/inbound-secrets/inbound-secrets.service.js.map +0 -1
  594. package/dist/modules/inbound-secrets/path-traversal.js.map +0 -1
  595. package/dist/modules/instance-ai/compaction.service.d.ts +0 -24
  596. package/dist/modules/instance-ai/compaction.service.js +0 -213
  597. package/dist/modules/instance-ai/compaction.service.js.map +0 -1
  598. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.d.ts +0 -33
  599. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js +0 -145
  600. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js.map +0 -1
  601. package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.d.ts +0 -8
  602. package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.js.map +0 -1
  603. package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.d.ts +0 -5
  604. package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.js.map +0 -1
  605. package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.d.ts +0 -5
  606. package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.js.map +0 -1
  607. package/dist/modules/instance-ai/snapshot-pruning.service.d.ts +0 -17
  608. package/dist/modules/instance-ai/snapshot-pruning.service.js +0 -89
  609. package/dist/modules/instance-ai/snapshot-pruning.service.js.map +0 -1
  610. package/dist/modules/instance-ai/storage/typeorm-composite-store.d.ts +0 -9
  611. package/dist/modules/instance-ai/storage/typeorm-composite-store.js +0 -33
  612. package/dist/modules/instance-ai/storage/typeorm-composite-store.js.map +0 -1
  613. package/dist/modules/instance-ai/storage/typeorm-memory-storage.d.ts +0 -96
  614. package/dist/modules/instance-ai/storage/typeorm-memory-storage.js +0 -864
  615. package/dist/modules/instance-ai/storage/typeorm-memory-storage.js.map +0 -1
  616. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.d.ts +0 -44
  617. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js +0 -156
  618. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js.map +0 -1
  619. package/dist/scaling/multi-main-setup-legacy.d.ts +0 -25
  620. package/dist/scaling/multi-main-setup-legacy.js +0 -75
  621. package/dist/scaling/multi-main-setup-legacy.js.map +0 -1
  622. package/dist/scaling/multi-main-setup-v2.d.ts +0 -25
  623. package/dist/scaling/multi-main-setup-v2.js +0 -143
  624. package/dist/scaling/multi-main-setup-v2.js.map +0 -1
  625. package/dist/scaling/multi-main-setup.types.d.ts +0 -6
  626. package/dist/scaling/multi-main-setup.types.js.map +0 -1
  627. /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.d.ts +0 -0
  628. /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.js +0 -0
@@ -9,16 +9,24 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.N8nMemory = void 0;
12
+ exports.N8nMemoryImpl = exports.N8nMemory = void 0;
13
13
  const agents_1 = require("@n8n/agents");
14
14
  const di_1 = require("@n8n/di");
15
15
  const typeorm_1 = require("@n8n/typeorm");
16
- const n8n_workflow_1 = require("n8n-workflow");
16
+ const response_helper_1 = require("../../../response-helper");
17
+ const agent_memory_entry_cursor_entity_1 = require("../entities/agent-memory-entry-cursor.entity");
18
+ const agent_memory_entry_entity_1 = require("../entities/agent-memory-entry.entity");
19
+ const agent_memory_entry_lock_entity_1 = require("../entities/agent-memory-entry-lock.entity");
20
+ const agent_memory_entry_source_entity_1 = require("../entities/agent-memory-entry-source.entity");
17
21
  const agent_observation_cursor_entity_1 = require("../entities/agent-observation-cursor.entity");
18
22
  const agent_observation_lock_entity_1 = require("../entities/agent-observation-lock.entity");
19
23
  const agent_observation_entity_1 = require("../entities/agent-observation.entity");
20
24
  const agent_thread_entity_1 = require("../entities/agent-thread.entity");
21
25
  const agent_message_repository_1 = require("../repositories/agent-message.repository");
26
+ const agent_memory_entry_cursor_repository_1 = require("../repositories/agent-memory-entry-cursor.repository");
27
+ const agent_memory_entry_lock_repository_1 = require("../repositories/agent-memory-entry-lock.repository");
28
+ const agent_memory_entry_source_repository_1 = require("../repositories/agent-memory-entry-source.repository");
29
+ const agent_memory_entry_repository_1 = require("../repositories/agent-memory-entry.repository");
22
30
  const agent_observation_cursor_repository_1 = require("../repositories/agent-observation-cursor.repository");
23
31
  const agent_observation_lock_repository_1 = require("../repositories/agent-observation-lock.repository");
24
32
  const agent_observation_repository_1 = require("../repositories/agent-observation.repository");
@@ -26,13 +34,61 @@ const agent_resource_repository_1 = require("../repositories/agent-resource.repo
26
34
  const agent_thread_repository_1 = require("../repositories/agent-thread.repository");
27
35
  const estimateObservationTokens = (text) => Math.ceil(text.length / 4);
28
36
  let N8nMemory = class N8nMemory {
29
- constructor(threadRepository, messageRepository, resourceRepository, observationRepository, observationCursorRepository, observationLockRepository) {
37
+ constructor(threadRepository, messageRepository, resourceRepository, observationRepository, observationCursorRepository, observationLockRepository, memoryEntryRepository, memoryEntryLockRepository, memoryEntrySourceRepository, memoryEntryCursorRepository) {
30
38
  this.threadRepository = threadRepository;
31
39
  this.messageRepository = messageRepository;
32
40
  this.resourceRepository = resourceRepository;
33
41
  this.observationRepository = observationRepository;
34
42
  this.observationCursorRepository = observationCursorRepository;
35
43
  this.observationLockRepository = observationLockRepository;
44
+ this.memoryEntryRepository = memoryEntryRepository;
45
+ this.memoryEntryLockRepository = memoryEntryLockRepository;
46
+ this.memoryEntrySourceRepository = memoryEntrySourceRepository;
47
+ this.memoryEntryCursorRepository = memoryEntryCursorRepository;
48
+ }
49
+ getImplementation(agentId) {
50
+ return new N8nMemoryImpl(agentId, this.threadRepository, this.messageRepository, this.resourceRepository, this.observationRepository, this.observationCursorRepository, this.observationLockRepository, this.memoryEntryRepository, this.memoryEntryLockRepository, this.memoryEntrySourceRepository, this.memoryEntryCursorRepository);
51
+ }
52
+ };
53
+ exports.N8nMemory = N8nMemory;
54
+ exports.N8nMemory = N8nMemory = __decorate([
55
+ (0, di_1.Service)(),
56
+ __metadata("design:paramtypes", [agent_thread_repository_1.AgentThreadRepository,
57
+ agent_message_repository_1.AgentMessageRepository,
58
+ agent_resource_repository_1.AgentResourceRepository,
59
+ agent_observation_repository_1.AgentObservationRepository,
60
+ agent_observation_cursor_repository_1.AgentObservationCursorRepository,
61
+ agent_observation_lock_repository_1.AgentObservationLockRepository,
62
+ agent_memory_entry_repository_1.AgentMemoryEntryRepository,
63
+ agent_memory_entry_lock_repository_1.AgentMemoryEntryLockRepository,
64
+ agent_memory_entry_source_repository_1.AgentMemoryEntrySourceRepository,
65
+ agent_memory_entry_cursor_repository_1.AgentMemoryEntryCursorRepository])
66
+ ], N8nMemory);
67
+ class N8nMemoryImpl {
68
+ constructor(agentId, threadRepository, messageRepository, resourceRepository, observationRepository, observationCursorRepository, observationLockRepository, memoryEntryRepository, memoryEntryLockRepository, memoryEntrySourceRepository, memoryEntryCursorRepository) {
69
+ this.agentId = agentId;
70
+ this.threadRepository = threadRepository;
71
+ this.messageRepository = messageRepository;
72
+ this.resourceRepository = resourceRepository;
73
+ this.observationRepository = observationRepository;
74
+ this.observationCursorRepository = observationCursorRepository;
75
+ this.observationLockRepository = observationLockRepository;
76
+ this.memoryEntryRepository = memoryEntryRepository;
77
+ this.memoryEntryLockRepository = memoryEntryLockRepository;
78
+ this.memoryEntrySourceRepository = memoryEntrySourceRepository;
79
+ this.memoryEntryCursorRepository = memoryEntryCursorRepository;
80
+ this.episodic = {
81
+ saveEntryWithSources: async (entry, sources) => await this.saveEpisodicMemoryEntryWithSources(entry, sources),
82
+ searchEntries: async (scope, query, opts) => await this.searchEpisodicMemoryEntries(scope, query, opts),
83
+ getEntrySources: async (entryIds) => await this.getEpisodicMemoryEntrySources(entryIds),
84
+ applyReflection: async (scope, reflection) => await this.applyEpisodicMemoryReflection(scope, reflection),
85
+ getCursor: async (scope) => await this.getEpisodicMemoryCursor(scope),
86
+ setCursor: async (cursor) => await this.setEpisodicMemoryCursor(cursor),
87
+ taskLock: {
88
+ acquire: async (resourceId, opts) => await this.acquireEpisodicMemoryTaskLock(resourceId, opts),
89
+ release: async (handle) => await this.releaseEpisodicMemoryTaskLock(handle),
90
+ },
91
+ };
36
92
  }
37
93
  async getThread(threadId) {
38
94
  const entity = await this.threadRepository.findOneBy({ id: threadId });
@@ -69,33 +125,50 @@ let N8nMemory = class N8nMemory {
69
125
  }
70
126
  async deleteThread(threadId) {
71
127
  await this.threadRepository.manager.transaction(async (trx) => {
72
- const legacyScope = { scopeKind: 'thread', scopeId: threadId };
73
- const resourceScope = {
74
- scopeKind: 'thread',
75
- scopeId: (0, typeorm_1.Like)(`${(0, agents_1.createObservationLogThreadScopePrefix)(threadId)}%`),
76
- };
77
- for (const scope of [legacyScope, resourceScope]) {
78
- await trx.delete(agent_observation_entity_1.AgentObservationEntity, scope);
79
- await trx.delete(agent_observation_cursor_entity_1.AgentObservationCursorEntity, scope);
80
- await trx.delete(agent_observation_lock_entity_1.AgentObservationLockEntity, scope);
81
- }
128
+ await this.dropEpisodicEntriesWithoutSources(trx, threadId);
129
+ const observationScope = { agentId: this.agentId, observationScopeId: threadId };
130
+ await trx.delete(agent_observation_entity_1.AgentObservationEntity, observationScope);
131
+ await trx.delete(agent_observation_cursor_entity_1.AgentObservationCursorEntity, observationScope);
132
+ await trx.delete(agent_observation_lock_entity_1.AgentObservationLockEntity, observationScope);
133
+ await trx.delete(agent_memory_entry_cursor_entity_1.AgentMemoryEntryCursorEntity, observationScope);
82
134
  await trx.delete(agent_thread_entity_1.AgentThreadEntity, { id: threadId });
83
135
  });
84
136
  }
85
137
  async deleteThreadsByPrefix(threadIdPrefix) {
86
- const scopeId = (0, typeorm_1.Like)(`${threadIdPrefix}%`);
87
- const resourceScopeId = (0, typeorm_1.Like)(`${(0, agents_1.createObservationLogThreadScopePrefix)(threadIdPrefix)}%`);
138
+ const observationScopeId = (0, typeorm_1.Like)(`${threadIdPrefix}%`);
88
139
  await this.threadRepository.manager.transaction(async (trx) => {
89
- for (const scope of [
90
- { scopeKind: 'thread', scopeId },
91
- { scopeKind: 'thread', scopeId: resourceScopeId },
92
- ]) {
93
- await trx.delete(agent_observation_entity_1.AgentObservationEntity, scope);
94
- await trx.delete(agent_observation_cursor_entity_1.AgentObservationCursorEntity, scope);
95
- await trx.delete(agent_observation_lock_entity_1.AgentObservationLockEntity, scope);
96
- }
97
- await trx.delete(agent_thread_entity_1.AgentThreadEntity, { id: scopeId });
140
+ await this.dropEpisodicEntriesWithoutSources(trx, observationScopeId);
141
+ const observationScope = { agentId: this.agentId, observationScopeId };
142
+ await trx.delete(agent_observation_entity_1.AgentObservationEntity, observationScope);
143
+ await trx.delete(agent_observation_cursor_entity_1.AgentObservationCursorEntity, observationScope);
144
+ await trx.delete(agent_observation_lock_entity_1.AgentObservationLockEntity, observationScope);
145
+ await trx.delete(agent_memory_entry_cursor_entity_1.AgentMemoryEntryCursorEntity, observationScope);
146
+ await trx.delete(agent_thread_entity_1.AgentThreadEntity, { id: observationScopeId });
147
+ });
148
+ }
149
+ async dropEpisodicEntriesWithoutSources(trx, threadId) {
150
+ const sourceRepo = trx.getRepository(agent_memory_entry_source_entity_1.AgentMemoryEntrySourceEntity);
151
+ const entryRepo = trx.getRepository(agent_memory_entry_entity_1.AgentMemoryEntryEntity);
152
+ const affectedSources = await sourceRepo.find({
153
+ select: { memoryEntryId: true },
154
+ where: { agentId: this.agentId, threadId },
98
155
  });
156
+ const affectedEntryIds = (0, agents_1.uniqueStrings)(affectedSources.map((source) => source.memoryEntryId));
157
+ if (affectedEntryIds.length === 0)
158
+ return;
159
+ await trx.delete(agent_memory_entry_source_entity_1.AgentMemoryEntrySourceEntity, {
160
+ agentId: this.agentId,
161
+ threadId,
162
+ });
163
+ const remainingSources = await sourceRepo.find({
164
+ select: { memoryEntryId: true },
165
+ where: { agentId: this.agentId, memoryEntryId: (0, typeorm_1.In)(affectedEntryIds) },
166
+ });
167
+ const entriesWithSources = new Set(remainingSources.map((source) => source.memoryEntryId));
168
+ const orphanedEntryIds = affectedEntryIds.filter((id) => !entriesWithSources.has(id));
169
+ if (orphanedEntryIds.length === 0)
170
+ return;
171
+ await entryRepo.update({ agentId: this.agentId, id: (0, typeorm_1.In)(orphanedEntryIds), status: 'active' }, (0, agents_1.droppedLifecycleState)());
99
172
  }
100
173
  async getMessages(threadId, opts) {
101
174
  const where = {
@@ -148,14 +221,13 @@ let N8nMemory = class N8nMemory {
148
221
  if (rows.length === 0)
149
222
  return [];
150
223
  const entities = rows.map((row) => this.observationRepository.create({
151
- scopeKind: row.scopeKind,
152
- scopeId: row.scopeId,
224
+ agentId: this.agentId,
225
+ observationScopeId: row.observationScopeId,
153
226
  marker: row.marker,
154
227
  text: row.text,
155
228
  parentId: row.parentId ?? null,
156
229
  tokenCount: row.tokenCount ?? estimateObservationTokens(row.text),
157
- status: 'active',
158
- supersededBy: null,
230
+ ...(0, agents_1.activeLifecycleState)(),
159
231
  createdAt: row.createdAt,
160
232
  }));
161
233
  const saved = await this.observationRepository.save(entities);
@@ -166,8 +238,8 @@ let N8nMemory = class N8nMemory {
166
238
  }
167
239
  async getObservationLog(opts) {
168
240
  const baseWhere = {
169
- scopeKind: opts.scopeKind,
170
- scopeId: opts.scopeId,
241
+ agentId: this.agentId,
242
+ observationScopeId: opts.observationScopeId,
171
243
  ...(opts.status !== undefined && { status: opts.status }),
172
244
  ...(opts.parentId !== undefined && { parentId: opts.parentId ?? (0, typeorm_1.IsNull)() }),
173
245
  };
@@ -181,13 +253,9 @@ let N8nMemory = class N8nMemory {
181
253
  });
182
254
  return entities.map((e) => this.toObservationLogEntry(e));
183
255
  }
184
- async getMessagesForScope(scopeKind, scopeId, opts) {
185
- if (scopeKind !== 'thread') {
186
- throw new n8n_workflow_1.UnexpectedError(`getMessagesForScope: scopeKind='${scopeKind}' is not supported in observational memory v1`);
187
- }
256
+ async getMessagesForObservationScope(observationScopeId, opts) {
188
257
  const baseWhere = {
189
- threadId: scopeId,
190
- ...(opts?.resourceId !== undefined && { resourceId: opts.resourceId }),
258
+ threadId: observationScopeId,
191
259
  };
192
260
  const where = opts?.since
193
261
  ? [
@@ -208,20 +276,20 @@ let N8nMemory = class N8nMemory {
208
276
  async dropObservationLogEntries(ids) {
209
277
  if (ids.length === 0)
210
278
  return;
211
- await this.observationRepository.update({ id: (0, typeorm_1.In)(ids) }, { status: 'dropped', supersededBy: null });
279
+ await this.observationRepository.update({ id: (0, typeorm_1.In)(ids) }, (0, agents_1.droppedLifecycleState)());
212
280
  }
213
281
  async supersedeObservationLogEntries(ids, supersededBy) {
214
282
  if (ids.length === 0)
215
283
  return;
216
- await this.observationRepository.update({ id: (0, typeorm_1.In)(ids) }, { status: 'superseded', supersededBy });
284
+ await this.observationRepository.update({ id: (0, typeorm_1.In)(ids) }, (0, agents_1.supersededLifecycleState)(supersededBy));
217
285
  }
218
286
  async applyObservationLogReflection(scope, reflection) {
219
287
  return await this.observationRepository.manager.transaction(async (trx) => {
220
288
  const repo = trx.getRepository(agent_observation_entity_1.AgentObservationEntity);
221
289
  const activeEntries = await repo.find({
222
290
  where: {
223
- scopeKind: scope.scopeKind,
224
- scopeId: scope.scopeId,
291
+ agentId: this.agentId,
292
+ observationScopeId: scope.observationScopeId,
225
293
  status: 'active',
226
294
  },
227
295
  order: { createdAt: 'ASC', id: 'ASC' },
@@ -229,24 +297,31 @@ let N8nMemory = class N8nMemory {
229
297
  const normalized = (0, agents_1.normalizeObservationLogReflection)(activeEntries.map((entry) => this.toObservationLogEntry(entry)), reflection);
230
298
  const inserted = normalized.merge.length
231
299
  ? await repo.save(normalized.merge.map((entry) => repo.create({
232
- scopeKind: scope.scopeKind,
233
- scopeId: scope.scopeId,
300
+ agentId: this.agentId,
301
+ observationScopeId: scope.observationScopeId,
234
302
  marker: entry.marker,
235
303
  text: entry.text,
236
304
  parentId: entry.parentId ?? null,
237
305
  tokenCount: entry.tokenCount ?? estimateObservationTokens(entry.text),
238
- status: 'active',
239
- supersededBy: null,
306
+ ...(0, agents_1.activeLifecycleState)(),
240
307
  createdAt: entry.createdAt,
241
308
  })))
242
309
  : [];
243
310
  if (normalized.drop.length > 0) {
244
- await repo.update({ scopeKind: scope.scopeKind, scopeId: scope.scopeId, id: (0, typeorm_1.In)(normalized.drop) }, { status: 'dropped', supersededBy: null });
311
+ await repo.update({
312
+ agentId: this.agentId,
313
+ observationScopeId: scope.observationScopeId,
314
+ id: (0, typeorm_1.In)(normalized.drop),
315
+ }, (0, agents_1.droppedLifecycleState)());
245
316
  }
246
317
  for (const [index, merge] of normalized.merge.entries()) {
247
318
  const replacement = inserted[index];
248
319
  if (replacement && merge.supersedes.length > 0) {
249
- await repo.update({ scopeKind: scope.scopeKind, scopeId: scope.scopeId, id: (0, typeorm_1.In)(merge.supersedes) }, { status: 'superseded', supersededBy: replacement.id });
320
+ await repo.update({
321
+ agentId: this.agentId,
322
+ observationScopeId: scope.observationScopeId,
323
+ id: (0, typeorm_1.In)(merge.supersedes),
324
+ }, (0, agents_1.supersededLifecycleState)(replacement.id));
250
325
  }
251
326
  }
252
327
  return {
@@ -256,13 +331,15 @@ let N8nMemory = class N8nMemory {
256
331
  };
257
332
  });
258
333
  }
259
- async getCursor(scopeKind, scopeId) {
260
- const entity = await this.observationCursorRepository.findOneBy({ scopeKind, scopeId });
334
+ async getCursor(observationScopeId) {
335
+ const entity = await this.observationCursorRepository.findOneBy({
336
+ agentId: this.agentId,
337
+ observationScopeId,
338
+ });
261
339
  if (!entity)
262
340
  return null;
263
341
  return {
264
- scopeKind: entity.scopeKind,
265
- scopeId: entity.scopeId,
342
+ observationScopeId: entity.observationScopeId,
266
343
  lastObservedMessageId: entity.lastObservedMessageId,
267
344
  lastObservedAt: entity.lastObservedAt,
268
345
  updatedAt: entity.updatedAt,
@@ -270,57 +347,406 @@ let N8nMemory = class N8nMemory {
270
347
  }
271
348
  async setCursor(cursor) {
272
349
  await this.observationCursorRepository.upsert({
273
- scopeKind: cursor.scopeKind,
274
- scopeId: cursor.scopeId,
350
+ agentId: this.agentId,
351
+ observationScopeId: cursor.observationScopeId,
275
352
  lastObservedMessageId: cursor.lastObservedMessageId,
276
353
  lastObservedAt: cursor.lastObservedAt,
277
354
  updatedAt: cursor.updatedAt,
278
- }, { conflictPaths: ['scopeKind', 'scopeId'], skipUpdateIfNoValuesChanged: false });
355
+ }, {
356
+ conflictPaths: ['agentId', 'observationScopeId'],
357
+ skipUpdateIfNoValuesChanged: false,
358
+ });
279
359
  }
280
- async acquireObservationLogTaskLock(scopeKind, scopeId, taskKind, opts) {
360
+ async acquireObservationLogTaskLock(observationScopeId, taskKind, opts) {
281
361
  const now = new Date();
282
362
  const heldUntil = new Date(now.getTime() + opts.ttlMs);
283
363
  const updateResult = await this.observationLockRepository
284
364
  .createQueryBuilder()
285
365
  .update(agent_observation_lock_entity_1.AgentObservationLockEntity)
286
366
  .set({ taskKind, holderId: opts.holderId, heldUntil })
287
- .where('"scopeKind" = :scopeKind')
288
- .andWhere('"scopeId" = :scopeId')
367
+ .where('"agentId" = :agentId')
368
+ .andWhere('"observationScopeId" = :observationScopeId')
289
369
  .andWhere('"taskKind" = :taskKind')
290
370
  .andWhere('("holderId" = :holderId OR "heldUntil" <= :now)')
291
- .setParameters({ scopeKind, scopeId, taskKind, holderId: opts.holderId, now })
371
+ .setParameters({
372
+ agentId: this.agentId,
373
+ observationScopeId,
374
+ taskKind,
375
+ holderId: opts.holderId,
376
+ now,
377
+ })
292
378
  .execute();
293
379
  if ((updateResult.affected ?? 0) > 0) {
294
- return { scopeKind, scopeId, taskKind, holderId: opts.holderId, heldUntil };
380
+ return { observationScopeId, taskKind, holderId: opts.holderId, heldUntil };
295
381
  }
296
382
  await this.observationLockRepository
297
383
  .createQueryBuilder()
298
384
  .insert()
299
385
  .into(agent_observation_lock_entity_1.AgentObservationLockEntity)
300
- .values({ scopeKind, scopeId, taskKind, holderId: opts.holderId, heldUntil })
386
+ .values({
387
+ agentId: this.agentId,
388
+ observationScopeId,
389
+ taskKind,
390
+ holderId: opts.holderId,
391
+ heldUntil,
392
+ })
301
393
  .orIgnore()
302
394
  .execute();
303
395
  const claimed = await this.observationLockRepository.findOneBy({
304
- scopeKind,
305
- scopeId,
396
+ agentId: this.agentId,
397
+ observationScopeId,
306
398
  taskKind,
307
399
  holderId: opts.holderId,
308
400
  });
309
401
  if (!claimed)
310
402
  return null;
311
- return { scopeKind, scopeId, taskKind, holderId: opts.holderId, heldUntil };
403
+ return { observationScopeId, taskKind, holderId: opts.holderId, heldUntil };
312
404
  }
313
405
  async releaseObservationLogTaskLock(handle) {
314
406
  await this.releaseScopeLock(handle);
315
407
  }
316
408
  async releaseScopeLock(handle) {
317
409
  await this.observationLockRepository.delete({
318
- scopeKind: handle.scopeKind,
319
- scopeId: handle.scopeId,
410
+ agentId: this.agentId,
411
+ observationScopeId: handle.observationScopeId,
320
412
  taskKind: handle.taskKind,
321
413
  holderId: handle.holderId,
322
414
  });
323
415
  }
416
+ async acquireEpisodicMemoryTaskLock(resourceId, opts) {
417
+ await this.ensureResource(resourceId);
418
+ const now = new Date();
419
+ const heldUntil = new Date(now.getTime() + opts.ttlMs);
420
+ const updateResult = await this.memoryEntryLockRepository
421
+ .createQueryBuilder()
422
+ .update(agent_memory_entry_lock_entity_1.AgentMemoryEntryLockEntity)
423
+ .set({ holderId: opts.holderId, heldUntil })
424
+ .where('"agentId" = :agentId')
425
+ .andWhere('"resourceId" = :resourceId')
426
+ .andWhere('("holderId" = :holderId OR "heldUntil" <= :now)')
427
+ .setParameters({
428
+ agentId: this.agentId,
429
+ resourceId,
430
+ holderId: opts.holderId,
431
+ now,
432
+ })
433
+ .execute();
434
+ if ((updateResult.affected ?? 0) > 0) {
435
+ return { resourceId, holderId: opts.holderId, heldUntil };
436
+ }
437
+ await this.memoryEntryLockRepository
438
+ .createQueryBuilder()
439
+ .insert()
440
+ .into(agent_memory_entry_lock_entity_1.AgentMemoryEntryLockEntity)
441
+ .values({ agentId: this.agentId, resourceId, holderId: opts.holderId, heldUntil })
442
+ .orIgnore()
443
+ .execute();
444
+ const claimed = await this.memoryEntryLockRepository.findOneBy({
445
+ agentId: this.agentId,
446
+ resourceId,
447
+ holderId: opts.holderId,
448
+ });
449
+ if (!claimed)
450
+ return null;
451
+ return { resourceId, holderId: opts.holderId, heldUntil };
452
+ }
453
+ async releaseEpisodicMemoryTaskLock(handle) {
454
+ await this.memoryEntryLockRepository.delete({
455
+ agentId: this.agentId,
456
+ resourceId: handle.resourceId,
457
+ holderId: handle.holderId,
458
+ });
459
+ }
460
+ async saveEpisodicMemoryEntryWithSources(entry, sources) {
461
+ await this.ensureResource(entry.resourceId);
462
+ return await this.memoryEntryRepository.manager.transaction(async (trx) => {
463
+ const entryRepo = trx.getRepository(agent_memory_entry_entity_1.AgentMemoryEntryEntity);
464
+ const sourceRepo = trx.getRepository(agent_memory_entry_source_entity_1.AgentMemoryEntrySourceEntity);
465
+ const contentHash = entry.contentHash ?? (0, agents_1.hashEpisodicMemoryContent)(entry.content);
466
+ const now = new Date();
467
+ const entity = entryRepo.create({
468
+ agentId: this.agentId,
469
+ resourceId: entry.resourceId,
470
+ content: entry.content,
471
+ contentHash,
472
+ ...(0, agents_1.activeLifecycleState)(),
473
+ embeddingModel: entry.embeddingModel ?? null,
474
+ embedding: entry.embedding ?? null,
475
+ metadata: entry.metadata ?? null,
476
+ createdAt: entry.createdAt ?? now,
477
+ lastSeenAt: entry.lastSeenAt ?? now,
478
+ });
479
+ let persisted = null;
480
+ try {
481
+ const [saved] = await entryRepo.save([entity]);
482
+ persisted = saved ?? null;
483
+ }
484
+ catch (error) {
485
+ if (!(error instanceof Error) || !(0, response_helper_1.isUniqueConstraintError)(error))
486
+ throw error;
487
+ const existing = await entryRepo.findOneBy({
488
+ agentId: this.agentId,
489
+ resourceId: entry.resourceId,
490
+ contentHash,
491
+ });
492
+ if (!existing)
493
+ throw error;
494
+ (0, agents_1.markLifecycleActive)(existing);
495
+ existing.lastSeenAt = entry.lastSeenAt ?? now;
496
+ existing.updatedAt = now;
497
+ const [saved] = await entryRepo.save([existing]);
498
+ persisted = saved ?? existing;
499
+ }
500
+ if (!persisted)
501
+ return null;
502
+ for (const source of sources) {
503
+ const evidenceHash = (0, agents_1.hashEpisodicMemoryEvidence)(source.evidenceText);
504
+ const sourceEntity = sourceRepo.create({
505
+ agentId: this.agentId,
506
+ memoryEntryId: persisted.id,
507
+ observationId: source.observationId,
508
+ threadId: source.threadId,
509
+ evidenceHash,
510
+ evidenceText: source.evidenceText,
511
+ createdAt: source.createdAt,
512
+ });
513
+ try {
514
+ await sourceRepo.save([sourceEntity]);
515
+ }
516
+ catch (error) {
517
+ if (!(error instanceof Error) || !(0, response_helper_1.isUniqueConstraintError)(error))
518
+ throw error;
519
+ const existing = await sourceRepo.findOneBy({
520
+ agentId: this.agentId,
521
+ memoryEntryId: persisted.id,
522
+ observationId: source.observationId,
523
+ evidenceHash,
524
+ });
525
+ if (!existing)
526
+ throw error;
527
+ }
528
+ }
529
+ return this.toEpisodicMemoryEntry(persisted);
530
+ });
531
+ }
532
+ async searchEpisodicMemoryEntries(scope, query, opts) {
533
+ const statuses = opts?.includeStatuses ?? ['active'];
534
+ const entities = await this.memoryEntryRepository.find({
535
+ where: { agentId: this.agentId, resourceId: scope.resourceId, status: (0, typeorm_1.In)(statuses) },
536
+ });
537
+ return (0, agents_1.rankEpisodicMemoryEntries)(entities.map((entity) => this.toEpisodicMemoryEntry(entity)), query, opts);
538
+ }
539
+ async getEpisodicMemoryEntrySources(entryIds) {
540
+ if (entryIds.length === 0)
541
+ return [];
542
+ const entities = await this.memoryEntrySourceRepository.find({
543
+ where: { agentId: this.agentId, memoryEntryId: (0, typeorm_1.In)(entryIds) },
544
+ order: { createdAt: 'ASC', id: 'ASC' },
545
+ });
546
+ return entities.map((entity) => this.toEpisodicMemoryEntrySource(entity));
547
+ }
548
+ async applyEpisodicMemoryReflection(scope, reflection) {
549
+ return await this.memoryEntryRepository.manager.transaction(async (trx) => {
550
+ const entryRepo = trx.getRepository(agent_memory_entry_entity_1.AgentMemoryEntryEntity);
551
+ const sourceRepo = trx.getRepository(agent_memory_entry_source_entity_1.AgentMemoryEntrySourceEntity);
552
+ const actionIds = (0, agents_1.uniqueStrings)([
553
+ ...reflection.drop,
554
+ ...reflection.merge.flatMap((merge) => merge.supersedes),
555
+ ]);
556
+ if (actionIds.length === 0)
557
+ return { droppedIds: [], supersededIds: [], inserted: [] };
558
+ const activeEntries = await entryRepo.find({
559
+ where: {
560
+ agentId: this.agentId,
561
+ resourceId: scope.resourceId,
562
+ id: (0, typeorm_1.In)(actionIds),
563
+ status: 'active',
564
+ },
565
+ });
566
+ const activeIds = new Set(activeEntries.map((entry) => entry.id));
567
+ const normalized = (0, agents_1.normalizeFlatReflectionActions)({
568
+ activeIds,
569
+ drop: reflection.drop,
570
+ merge: reflection.merge,
571
+ normalizeMerge: (entry, supersedes) => ({ ...entry, supersedes }),
572
+ });
573
+ const now = new Date();
574
+ const replacementHashes = (0, agents_1.uniqueStrings)(normalized.merge.map((item) => item.entry.contentHash ?? (0, agents_1.hashEpisodicMemoryContent)(item.entry.content)));
575
+ const existingReplacements = replacementHashes.length
576
+ ? await entryRepo.find({
577
+ where: {
578
+ agentId: this.agentId,
579
+ resourceId: scope.resourceId,
580
+ contentHash: (0, typeorm_1.In)(replacementHashes),
581
+ },
582
+ })
583
+ : [];
584
+ const existingByHash = new Map(existingReplacements.map((entry) => [entry.contentHash, entry]));
585
+ const replacements = [];
586
+ for (const item of normalized.merge) {
587
+ const contentHash = item.entry.contentHash ?? (0, agents_1.hashEpisodicMemoryContent)(item.entry.content);
588
+ const existing = existingByHash.get(contentHash);
589
+ const update = {
590
+ ...(0, agents_1.activeLifecycleState)(),
591
+ lastSeenAt: item.entry.lastSeenAt ?? now,
592
+ updatedAt: now,
593
+ };
594
+ if (item.entry.embedding !== undefined)
595
+ update.embedding = item.entry.embedding;
596
+ if (item.entry.embeddingModel !== undefined) {
597
+ update.embeddingModel = item.entry.embeddingModel;
598
+ }
599
+ if (item.entry.metadata !== undefined)
600
+ update.metadata = item.entry.metadata;
601
+ if (existing) {
602
+ await entryRepo.update({ agentId: this.agentId, resourceId: scope.resourceId, id: existing.id }, update);
603
+ replacements.push({
604
+ ...existing,
605
+ ...update,
606
+ });
607
+ continue;
608
+ }
609
+ const entity = entryRepo.create({
610
+ agentId: this.agentId,
611
+ resourceId: scope.resourceId,
612
+ content: item.entry.content,
613
+ contentHash,
614
+ ...(0, agents_1.activeLifecycleState)(),
615
+ embeddingModel: item.entry.embeddingModel ?? null,
616
+ embedding: item.entry.embedding ?? null,
617
+ metadata: item.entry.metadata ?? null,
618
+ createdAt: item.entry.createdAt ?? now,
619
+ lastSeenAt: item.entry.lastSeenAt ?? now,
620
+ });
621
+ try {
622
+ const [persisted] = await entryRepo.save([entity]);
623
+ if (persisted) {
624
+ existingByHash.set(contentHash, persisted);
625
+ replacements.push(persisted);
626
+ }
627
+ }
628
+ catch (error) {
629
+ if (!(error instanceof Error) || !(0, response_helper_1.isUniqueConstraintError)(error))
630
+ throw error;
631
+ const persisted = await entryRepo.findOneBy({
632
+ agentId: this.agentId,
633
+ resourceId: scope.resourceId,
634
+ contentHash,
635
+ });
636
+ if (!persisted)
637
+ throw error;
638
+ await entryRepo.update({ agentId: this.agentId, resourceId: scope.resourceId, id: persisted.id }, update);
639
+ existingByHash.set(contentHash, persisted);
640
+ replacements.push({
641
+ ...persisted,
642
+ ...update,
643
+ });
644
+ }
645
+ }
646
+ const replacementIds = new Set(replacements.map((entry) => entry.id));
647
+ const effectiveDrop = normalized.drop.filter((id) => !replacementIds.has(id));
648
+ if (effectiveDrop.length > 0) {
649
+ await entryRepo.update({
650
+ agentId: this.agentId,
651
+ resourceId: scope.resourceId,
652
+ id: (0, typeorm_1.In)(effectiveDrop),
653
+ status: 'active',
654
+ }, (0, agents_1.droppedLifecycleState)());
655
+ }
656
+ const supersededIds = [];
657
+ for (const [index, item] of normalized.merge.entries()) {
658
+ const replacement = replacements[index];
659
+ if (!replacement)
660
+ continue;
661
+ const sourceRows = await sourceRepo.find({
662
+ where: { agentId: this.agentId, memoryEntryId: (0, typeorm_1.In)(item.supersedes) },
663
+ order: { createdAt: 'ASC', id: 'ASC' },
664
+ });
665
+ const existingReplacementSources = await sourceRepo.find({
666
+ where: { agentId: this.agentId, memoryEntryId: replacement.id },
667
+ });
668
+ const existingKeys = new Set(existingReplacementSources.map((source) => `${source.observationId}\n${source.evidenceHash}`));
669
+ const copiedSources = sourceRows.flatMap((source) => {
670
+ const key = `${source.observationId}\n${source.evidenceHash}`;
671
+ if (existingKeys.has(key))
672
+ return [];
673
+ existingKeys.add(key);
674
+ return [
675
+ sourceRepo.create({
676
+ agentId: this.agentId,
677
+ memoryEntryId: replacement.id,
678
+ observationId: source.observationId,
679
+ threadId: source.threadId,
680
+ evidenceHash: source.evidenceHash,
681
+ evidenceText: source.evidenceText,
682
+ createdAt: now,
683
+ }),
684
+ ];
685
+ });
686
+ if (copiedSources.length > 0)
687
+ await sourceRepo.save(copiedSources);
688
+ const itemSupersededIds = item.supersedes.filter((id) => id !== replacement.id);
689
+ if (itemSupersededIds.length > 0) {
690
+ await entryRepo.update({
691
+ agentId: this.agentId,
692
+ resourceId: scope.resourceId,
693
+ id: (0, typeorm_1.In)(itemSupersededIds),
694
+ status: 'active',
695
+ }, (0, agents_1.supersededLifecycleState)(replacement.id));
696
+ supersededIds.push(...itemSupersededIds);
697
+ }
698
+ }
699
+ return {
700
+ droppedIds: effectiveDrop,
701
+ supersededIds,
702
+ inserted: replacements.map((entry) => this.toEpisodicMemoryEntry(entry)),
703
+ };
704
+ });
705
+ }
706
+ async getEpisodicMemoryCursor(scope) {
707
+ const entity = await this.memoryEntryCursorRepository.findOneBy({
708
+ agentId: this.agentId,
709
+ observationScopeId: scope.observationScopeId,
710
+ });
711
+ if (!entity)
712
+ return null;
713
+ return {
714
+ observationScopeId: entity.observationScopeId,
715
+ lastIndexedObservationId: entity.lastIndexedObservationId,
716
+ lastIndexedObservationCreatedAt: entity.lastIndexedObservationCreatedAt,
717
+ updatedAt: entity.updatedAt,
718
+ };
719
+ }
720
+ async setEpisodicMemoryCursor(cursor) {
721
+ const cursorRow = {
722
+ agentId: this.agentId,
723
+ observationScopeId: cursor.observationScopeId,
724
+ lastIndexedObservationId: cursor.lastIndexedObservationId,
725
+ lastIndexedObservationCreatedAt: cursor.lastIndexedObservationCreatedAt,
726
+ updatedAt: cursor.updatedAt ?? new Date(),
727
+ };
728
+ await this.memoryEntryCursorRepository
729
+ .createQueryBuilder()
730
+ .insert()
731
+ .into(agent_memory_entry_cursor_entity_1.AgentMemoryEntryCursorEntity)
732
+ .values(cursorRow)
733
+ .orIgnore()
734
+ .execute();
735
+ await this.memoryEntryCursorRepository
736
+ .createQueryBuilder()
737
+ .update(agent_memory_entry_cursor_entity_1.AgentMemoryEntryCursorEntity)
738
+ .set(cursorRow)
739
+ .where('"agentId" = :agentId')
740
+ .andWhere('"observationScopeId" = :observationScopeId')
741
+ .andWhere('("lastIndexedObservationCreatedAt" < :lastIndexedObservationCreatedAt OR ("lastIndexedObservationCreatedAt" = :lastIndexedObservationCreatedAt AND "lastIndexedObservationId" < :lastIndexedObservationId))')
742
+ .setParameters({
743
+ agentId: this.agentId,
744
+ observationScopeId: cursor.observationScopeId,
745
+ lastIndexedObservationId: cursor.lastIndexedObservationId,
746
+ lastIndexedObservationCreatedAt: cursor.lastIndexedObservationCreatedAt,
747
+ })
748
+ .execute();
749
+ }
324
750
  describe() {
325
751
  return { name: 'n8n', connectionParams: {}, constructorName: this.constructor.name };
326
752
  }
@@ -333,8 +759,7 @@ let N8nMemory = class N8nMemory {
333
759
  toObservationLogEntry(entity) {
334
760
  return {
335
761
  id: entity.id,
336
- scopeKind: entity.scopeKind,
337
- scopeId: entity.scopeId,
762
+ observationScopeId: entity.observationScopeId,
338
763
  marker: entity.marker,
339
764
  text: entity.text,
340
765
  parentId: entity.parentId,
@@ -344,6 +769,32 @@ let N8nMemory = class N8nMemory {
344
769
  createdAt: entity.createdAt,
345
770
  };
346
771
  }
772
+ toEpisodicMemoryEntry(entity) {
773
+ return {
774
+ id: entity.id,
775
+ resourceId: entity.resourceId,
776
+ content: entity.content,
777
+ contentHash: entity.contentHash,
778
+ status: entity.status,
779
+ supersededBy: entity.supersededBy,
780
+ ...(entity.embedding ? { embedding: entity.embedding } : {}),
781
+ ...(entity.embeddingModel ? { embeddingModel: entity.embeddingModel } : {}),
782
+ metadata: entity.metadata,
783
+ createdAt: entity.createdAt,
784
+ updatedAt: entity.updatedAt,
785
+ lastSeenAt: entity.lastSeenAt,
786
+ };
787
+ }
788
+ toEpisodicMemoryEntrySource(entity) {
789
+ return {
790
+ id: entity.id,
791
+ memoryEntryId: entity.memoryEntryId,
792
+ observationId: entity.observationId,
793
+ threadId: entity.threadId,
794
+ evidenceText: entity.evidenceText,
795
+ createdAt: entity.createdAt,
796
+ };
797
+ }
347
798
  toThread(entity) {
348
799
  let metadata;
349
800
  if (entity.metadata) {
@@ -363,15 +814,6 @@ let N8nMemory = class N8nMemory {
363
814
  updatedAt: entity.updatedAt,
364
815
  };
365
816
  }
366
- };
367
- exports.N8nMemory = N8nMemory;
368
- exports.N8nMemory = N8nMemory = __decorate([
369
- (0, di_1.Service)(),
370
- __metadata("design:paramtypes", [agent_thread_repository_1.AgentThreadRepository,
371
- agent_message_repository_1.AgentMessageRepository,
372
- agent_resource_repository_1.AgentResourceRepository,
373
- agent_observation_repository_1.AgentObservationRepository,
374
- agent_observation_cursor_repository_1.AgentObservationCursorRepository,
375
- agent_observation_lock_repository_1.AgentObservationLockRepository])
376
- ], N8nMemory);
817
+ }
818
+ exports.N8nMemoryImpl = N8nMemoryImpl;
377
819
  //# sourceMappingURL=n8n-memory.js.map