n8n 2.22.4 → 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 (626) 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 -4
  89. package/dist/manual-execution.service.js +3 -0
  90. package/dist/manual-execution.service.js.map +1 -1
  91. package/dist/modules/agents/agent-execution.service.js +5 -5
  92. package/dist/modules/agents/agent-execution.service.js.map +1 -1
  93. package/dist/modules/agents/agent-sse-stream.js +17 -1
  94. package/dist/modules/agents/agent-sse-stream.js.map +1 -1
  95. package/dist/modules/agents/agents-tools.service.js +7 -5
  96. package/dist/modules/agents/agents-tools.service.js.map +1 -1
  97. package/dist/modules/agents/agents.controller.d.ts +29 -3
  98. package/dist/modules/agents/agents.controller.js +88 -7
  99. package/dist/modules/agents/agents.controller.js.map +1 -1
  100. package/dist/modules/agents/agents.module.d.ts +1 -1
  101. package/dist/modules/agents/agents.module.js +12 -6
  102. package/dist/modules/agents/agents.module.js.map +1 -1
  103. package/dist/modules/agents/agents.service.d.ts +7 -8
  104. package/dist/modules/agents/agents.service.js +120 -65
  105. package/dist/modules/agents/agents.service.js.map +1 -1
  106. package/dist/modules/agents/builder/agents-builder-model-recommendations.d.ts +1 -1
  107. package/dist/modules/agents/builder/agents-builder-model-recommendations.js +3 -3
  108. package/dist/modules/agents/builder/agents-builder-model-recommendations.js.map +1 -1
  109. package/dist/modules/agents/builder/agents-builder-prompts.d.ts +9 -17
  110. package/dist/modules/agents/builder/agents-builder-prompts.js +145 -549
  111. package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
  112. package/dist/modules/agents/builder/agents-builder-settings.service.js +2 -2
  113. package/dist/modules/agents/builder/agents-builder-settings.service.js.map +1 -1
  114. package/dist/modules/agents/builder/agents-builder-tools.service.js +10 -10
  115. package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
  116. package/dist/modules/agents/builder/agents-builder.service.d.ts +3 -1
  117. package/dist/modules/agents/builder/agents-builder.service.js +58 -9
  118. package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
  119. package/dist/modules/agents/builder/interactive/ask-credential.tool.js +2 -2
  120. package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
  121. package/dist/modules/agents/builder/interactive/ask-llm.tool.js +2 -2
  122. package/dist/modules/agents/builder/interactive/ask-llm.tool.js.map +1 -1
  123. package/dist/modules/agents/builder/interactive/ask-question.tool.js +2 -2
  124. package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -1
  125. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +2 -2
  126. package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -1
  127. package/dist/modules/agents/builder/prompts/config-mutation.prompt.d.ts +1 -0
  128. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +132 -0
  129. package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -0
  130. package/dist/modules/agents/builder/prompts/config-rules.prompt.d.ts +2 -0
  131. package/dist/modules/agents/builder/prompts/config-rules.prompt.js +63 -0
  132. package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -0
  133. package/dist/modules/agents/builder/prompts/llm-selection.prompt.d.ts +1 -0
  134. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +47 -0
  135. package/dist/modules/agents/builder/prompts/llm-selection.prompt.js.map +1 -0
  136. package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -0
  137. package/dist/modules/agents/builder/prompts/memory.prompt.js +60 -0
  138. package/dist/modules/agents/builder/prompts/memory.prompt.js.map +1 -0
  139. package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -0
  140. package/dist/modules/agents/builder/prompts/tools.prompt.js +81 -0
  141. package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -0
  142. package/dist/modules/agents/builder/skills/index.d.ts +2 -0
  143. package/dist/modules/agents/builder/skills/index.js +12 -0
  144. package/dist/modules/agents/builder/skills/index.js.map +1 -0
  145. package/dist/modules/agents/builder/skills/integrations.skill.d.ts +2 -0
  146. package/dist/modules/agents/builder/skills/integrations.skill.js +53 -0
  147. package/dist/modules/agents/builder/skills/integrations.skill.js.map +1 -0
  148. package/dist/modules/agents/builder/skills/research.skill.d.ts +2 -0
  149. package/dist/modules/agents/builder/skills/research.skill.js +42 -0
  150. package/dist/modules/agents/builder/skills/research.skill.js.map +1 -0
  151. package/dist/modules/agents/builder/skills/target-skills.skill.d.ts +2 -0
  152. package/dist/modules/agents/builder/skills/target-skills.skill.js +59 -0
  153. package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -0
  154. package/dist/modules/agents/entities/{agent-published-version.entity.d.ts → agent-history.entity.d.ts} +4 -7
  155. package/dist/modules/agents/entities/{agent-published-version.entity.js → agent-history.entity.js} +22 -34
  156. package/dist/modules/agents/entities/agent-history.entity.js.map +1 -0
  157. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.d.ts +7 -0
  158. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js +38 -0
  159. package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js.map +1 -0
  160. package/dist/modules/agents/entities/agent-memory-entry-lock.entity.d.ts +7 -0
  161. package/dist/modules/{instance-ai/entities/instance-ai-workflow-snapshot.entity.js → agents/entities/agent-memory-entry-lock.entity.js} +16 -19
  162. package/dist/modules/agents/entities/agent-memory-entry-lock.entity.js.map +1 -0
  163. package/dist/modules/agents/entities/agent-memory-entry-source.entity.d.ts +9 -0
  164. package/dist/modules/agents/entities/agent-memory-entry-source.entity.js +49 -0
  165. package/dist/modules/agents/entities/agent-memory-entry-source.entity.js.map +1 -0
  166. package/dist/modules/agents/entities/agent-memory-entry.entity.d.ts +15 -0
  167. package/dist/modules/agents/entities/agent-memory-entry.entity.js +65 -0
  168. package/dist/modules/agents/entities/agent-memory-entry.entity.js.map +1 -0
  169. package/dist/modules/agents/entities/agent-observation-cursor.entity.d.ts +2 -3
  170. package/dist/modules/agents/entities/agent-observation-cursor.entity.js +5 -4
  171. package/dist/modules/agents/entities/agent-observation-cursor.entity.js.map +1 -1
  172. package/dist/modules/agents/entities/agent-observation-lock.entity.d.ts +2 -3
  173. package/dist/modules/agents/entities/agent-observation-lock.entity.js +5 -4
  174. package/dist/modules/agents/entities/agent-observation-lock.entity.js.map +1 -1
  175. package/dist/modules/agents/entities/agent-observation.entity.d.ts +2 -3
  176. package/dist/modules/agents/entities/agent-observation.entity.js +6 -5
  177. package/dist/modules/agents/entities/agent-observation.entity.js.map +1 -1
  178. package/dist/modules/agents/entities/agent.entity.d.ts +3 -5
  179. package/dist/modules/agents/entities/agent.entity.js +7 -14
  180. package/dist/modules/agents/entities/agent.entity.js.map +1 -1
  181. package/dist/modules/agents/episodic-memory.d.ts +2 -0
  182. package/dist/modules/agents/episodic-memory.js +12 -0
  183. package/dist/modules/agents/episodic-memory.js.map +1 -0
  184. package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +2 -1
  185. package/dist/modules/agents/integrations/agent-chat-bridge.js +19 -5
  186. package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
  187. package/dist/modules/agents/integrations/agent-schedule.service.js +10 -6
  188. package/dist/modules/agents/integrations/agent-schedule.service.js.map +1 -1
  189. package/dist/modules/agents/integrations/chat-integration.service.js +1 -1
  190. package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -1
  191. package/dist/modules/agents/integrations/n8n-memory.d.ts +41 -18
  192. package/dist/modules/agents/integrations/n8n-memory.js +519 -77
  193. package/dist/modules/agents/integrations/n8n-memory.js.map +1 -1
  194. package/dist/modules/agents/integrations/platforms/slack-integration.js +2 -12
  195. package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
  196. package/dist/modules/agents/integrations/rich-interaction-tool.d.ts +1 -1
  197. package/dist/modules/agents/integrations/rich-interaction-tool.js +2 -2
  198. package/dist/modules/agents/integrations/rich-interaction-tool.js.map +1 -1
  199. package/dist/modules/agents/integrations/slack-app-setup.service.d.ts +52 -0
  200. package/dist/modules/agents/integrations/slack-app-setup.service.js +316 -0
  201. package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -0
  202. package/dist/modules/agents/json-config/from-json-config.d.ts +2 -3
  203. package/dist/modules/agents/json-config/from-json-config.js +76 -61
  204. package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
  205. package/dist/modules/agents/json-config/schema-text-serializer.js +2 -1
  206. package/dist/modules/agents/json-config/schema-text-serializer.js.map +1 -1
  207. package/dist/modules/agents/repositories/agent-history.repository.d.ts +19 -0
  208. package/dist/modules/agents/repositories/agent-history.repository.js +51 -0
  209. package/dist/modules/agents/repositories/agent-history.repository.js.map +1 -0
  210. package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.d.ts +5 -0
  211. package/dist/modules/{instance-ai/repositories/instance-ai-workflow-snapshot.repository.js → agents/repositories/agent-memory-entry-cursor.repository.js} +8 -8
  212. package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.js.map +1 -0
  213. package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.d.ts +5 -0
  214. package/dist/modules/{instance-ai/repositories/instance-ai-observational-memory.repository.js → agents/repositories/agent-memory-entry-lock.repository.js} +8 -8
  215. package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.js.map +1 -0
  216. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.d.ts +5 -0
  217. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js +26 -0
  218. package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js.map +1 -0
  219. package/dist/modules/agents/repositories/agent-memory-entry.repository.d.ts +5 -0
  220. package/dist/modules/agents/repositories/agent-memory-entry.repository.js +26 -0
  221. package/dist/modules/agents/repositories/agent-memory-entry.repository.js.map +1 -0
  222. package/dist/modules/agents/repositories/agent.repository.js +3 -3
  223. package/dist/modules/agents/repositories/agent.repository.js.map +1 -1
  224. package/dist/modules/agents/runtime/agent-secure-runtime.js +5 -5
  225. package/dist/modules/agents/runtime/agent-secure-runtime.js.map +1 -1
  226. package/dist/modules/agents/tools/environment-tool.d.ts +1 -1
  227. package/dist/modules/agents/tools/environment-tool.js +3 -3
  228. package/dist/modules/agents/tools/environment-tool.js.map +1 -1
  229. package/dist/modules/agents/tools/node-tool-factory.js +5 -5
  230. package/dist/modules/agents/tools/node-tool-factory.js.map +1 -1
  231. package/dist/modules/agents/tools/workflow-tool-factory.js +3 -3
  232. package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -1
  233. package/dist/modules/agents/tracing/builder-telemetry.d.ts +2 -3
  234. package/dist/modules/agents/tracing/builder-telemetry.js +36 -3
  235. package/dist/modules/agents/tracing/builder-telemetry.js.map +1 -1
  236. package/dist/modules/agents/utils/agent-draft.utils.js +1 -2
  237. package/dist/modules/agents/utils/agent-draft.utils.js.map +1 -1
  238. package/dist/modules/agents/utils/agent-memory-scope.d.ts +3 -0
  239. package/dist/modules/agents/utils/agent-memory-scope.js +15 -0
  240. package/dist/modules/agents/utils/agent-memory-scope.js.map +1 -0
  241. package/dist/modules/chat-hub/chat-hub.constants.js +4 -0
  242. package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
  243. package/dist/modules/chat-hub/context-limits.js +1 -0
  244. package/dist/modules/chat-hub/context-limits.js.map +1 -1
  245. package/dist/modules/dynamic-credentials.ee/constants.d.ts +3 -0
  246. package/dist/modules/dynamic-credentials.ee/constants.js +7 -0
  247. package/dist/modules/dynamic-credentials.ee/constants.js.map +1 -0
  248. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js +14 -2
  249. package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js.map +1 -1
  250. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.d.ts +2 -2
  251. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js +18 -4
  252. package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js.map +1 -1
  253. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.d.ts +1 -1
  254. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js +4 -1
  255. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js.map +1 -1
  256. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.d.ts +4 -0
  257. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js +11 -0
  258. package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js.map +1 -0
  259. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.d.ts +7 -0
  260. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js +40 -0
  261. package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js.map +1 -0
  262. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.d.ts +3 -1
  263. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js +6 -3
  264. package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -1
  265. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.d.ts +2 -0
  266. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js +22 -0
  267. package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js.map +1 -1
  268. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.d.ts +3 -1
  269. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +7 -3
  270. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -1
  271. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.d.ts +4 -1
  272. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js +11 -3
  273. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -1
  274. package/dist/modules/dynamic-credentials.ee/services/index.d.ts +2 -0
  275. package/dist/modules/dynamic-credentials.ee/services/index.js +2 -0
  276. package/dist/modules/dynamic-credentials.ee/services/index.js.map +1 -1
  277. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.d.ts +14 -0
  278. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js +70 -0
  279. package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js.map +1 -0
  280. package/dist/modules/insights/insights-collection.service.js +1 -1
  281. package/dist/modules/insights/insights-collection.service.js.map +1 -1
  282. package/dist/modules/instance-ai/entities/index.d.ts +6 -2
  283. package/dist/modules/instance-ai/entities/index.js +9 -5
  284. package/dist/modules/instance-ai/entities/index.js.map +1 -1
  285. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.d.ts +12 -0
  286. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js +54 -0
  287. package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js.map +1 -0
  288. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.d.ts +6 -0
  289. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js +33 -0
  290. package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js.map +1 -0
  291. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.d.ts +8 -0
  292. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js +37 -0
  293. package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js.map +1 -0
  294. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.d.ts +12 -0
  295. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js +52 -0
  296. package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js.map +1 -0
  297. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.d.ts +19 -0
  298. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js +82 -0
  299. package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js.map +1 -0
  300. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.d.ts +2 -0
  301. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js +8 -0
  302. package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js.map +1 -1
  303. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.d.ts +12 -2
  304. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js +40 -4
  305. package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js.map +1 -1
  306. package/dist/modules/instance-ai/eval/execution.service.d.ts +8 -2
  307. package/dist/modules/instance-ai/eval/execution.service.js +137 -47
  308. package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
  309. package/dist/modules/instance-ai/eval/llm-wire-server.d.ts +31 -0
  310. package/dist/modules/instance-ai/eval/llm-wire-server.js +127 -0
  311. package/dist/modules/instance-ai/eval/llm-wire-server.js.map +1 -0
  312. package/dist/modules/instance-ai/eval/openai-envelope.d.ts +6 -0
  313. package/dist/modules/instance-ai/eval/openai-envelope.js +96 -0
  314. package/dist/modules/instance-ai/eval/openai-envelope.js.map +1 -0
  315. package/dist/modules/instance-ai/eval/proxy-loopback.d.ts +1 -0
  316. package/dist/modules/instance-ai/eval/proxy-loopback.js +44 -0
  317. package/dist/modules/instance-ai/eval/proxy-loopback.js.map +1 -0
  318. package/dist/modules/instance-ai/eval/sub-agent-eval.service.js +29 -7
  319. package/dist/modules/instance-ai/eval/sub-agent-eval.service.js.map +1 -1
  320. package/dist/modules/instance-ai/eval/workflow-analysis.d.ts +7 -1
  321. package/dist/modules/instance-ai/eval/workflow-analysis.js +178 -3
  322. package/dist/modules/instance-ai/eval/workflow-analysis.js.map +1 -1
  323. package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +6 -6
  324. package/dist/modules/instance-ai/instance-ai-memory.service.js +44 -85
  325. package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
  326. package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +2 -1
  327. package/dist/modules/instance-ai/instance-ai-settings.service.js +11 -22
  328. package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
  329. package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +2 -0
  330. package/dist/modules/instance-ai/instance-ai.adapter.service.js +105 -13
  331. package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
  332. package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -1
  333. package/dist/modules/instance-ai/instance-ai.module.js +10 -6
  334. package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
  335. package/dist/modules/instance-ai/instance-ai.service.d.ts +34 -12
  336. package/dist/modules/instance-ai/instance-ai.service.js +724 -264
  337. package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
  338. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +4 -1
  339. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +3 -1
  340. package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -1
  341. package/dist/modules/instance-ai/message-parser.d.ts +3 -3
  342. package/dist/modules/instance-ai/message-parser.js +65 -61
  343. package/dist/modules/instance-ai/message-parser.js.map +1 -1
  344. package/dist/modules/instance-ai/node-definition-resolver.js +12 -48
  345. package/dist/modules/instance-ai/node-definition-resolver.js.map +1 -1
  346. package/dist/modules/instance-ai/repositories/index.d.ts +4 -2
  347. package/dist/modules/instance-ai/repositories/index.js +9 -5
  348. package/dist/modules/instance-ai/repositories/index.js.map +1 -1
  349. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.d.ts +5 -0
  350. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js +26 -0
  351. package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js.map +1 -0
  352. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.d.ts +5 -0
  353. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js +26 -0
  354. package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js.map +1 -0
  355. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.d.ts +5 -0
  356. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js +26 -0
  357. package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js.map +1 -0
  358. package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.d.ts +5 -0
  359. package/dist/modules/{agents/repositories/agent-published-version.repository.js → instance-ai/repositories/instance-ai-observation.repository.js} +8 -17
  360. package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.js.map +1 -0
  361. package/dist/modules/instance-ai/storage/db-snapshot-storage.d.ts +2 -0
  362. package/dist/modules/instance-ai/storage/db-snapshot-storage.js +12 -2
  363. package/dist/modules/instance-ai/storage/db-snapshot-storage.js.map +1 -1
  364. package/dist/modules/instance-ai/storage/index.d.ts +2 -3
  365. package/dist/modules/instance-ai/storage/index.js +5 -7
  366. package/dist/modules/instance-ai/storage/index.js.map +1 -1
  367. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.d.ts +15 -0
  368. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js +94 -0
  369. package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js.map +1 -0
  370. package/dist/modules/instance-ai/storage/typeorm-agent-memory.d.ts +94 -0
  371. package/dist/modules/instance-ai/storage/typeorm-agent-memory.js +324 -0
  372. package/dist/modules/instance-ai/storage/typeorm-agent-memory.js.map +1 -0
  373. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.d.ts +37 -0
  374. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js +212 -0
  375. package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js.map +1 -0
  376. package/dist/modules/instance-ai/web-research/fetch-and-extract.js +34 -11
  377. package/dist/modules/instance-ai/web-research/fetch-and-extract.js.map +1 -1
  378. package/dist/modules/mcp/mcp.service.js +5 -5
  379. package/dist/modules/mcp/mcp.service.js.map +1 -1
  380. package/dist/modules/mcp/tools/schemas.d.ts +24 -24
  381. package/dist/modules/mcp/tools/search-projects.tool.js +59 -13
  382. package/dist/modules/mcp/tools/search-projects.tool.js.map +1 -1
  383. package/dist/modules/mcp/tools/test-workflow.tool.d.ts +2 -2
  384. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.d.ts +35 -0
  385. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js +88 -0
  386. package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js.map +1 -0
  387. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.d.ts +3 -2
  388. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +41 -9
  389. package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
  390. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.d.ts +13 -0
  391. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js +87 -0
  392. package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js.map +1 -0
  393. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +2 -1
  394. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +42 -6
  395. package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
  396. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.d.ts +2 -1
  397. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +5 -1
  398. package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
  399. package/dist/modules/mcp/tools/workflow-validation.utils.js +1 -1
  400. package/dist/modules/mcp/tools/workflow-validation.utils.js.map +1 -1
  401. package/dist/modules/mcp-registry/mcp-registry-test.controller.js +5 -1
  402. package/dist/modules/mcp-registry/mcp-registry-test.controller.js.map +1 -1
  403. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.d.ts +18 -0
  404. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js +73 -0
  405. package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js.map +1 -0
  406. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.d.ts +5 -0
  407. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js +31 -0
  408. package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js.map +1 -0
  409. package/dist/modules/n8n-packages/io/package-writer.d.ts +6 -0
  410. package/dist/{scaling/multi-main-setup.types.js → modules/n8n-packages/io/package-writer.js} +1 -1
  411. package/dist/modules/n8n-packages/io/package-writer.js.map +1 -0
  412. package/dist/modules/n8n-packages/io/slug.utils.d.ts +1 -0
  413. package/dist/modules/n8n-packages/io/slug.utils.js +16 -0
  414. package/dist/modules/n8n-packages/io/slug.utils.js.map +1 -0
  415. package/dist/modules/n8n-packages/io/tar/tar-package-writer.d.ts +9 -0
  416. package/dist/modules/n8n-packages/io/tar/tar-package-writer.js +71 -0
  417. package/dist/modules/n8n-packages/io/tar/tar-package-writer.js.map +1 -0
  418. package/dist/modules/n8n-packages/n8n-packages.controller.d.ts +10 -0
  419. package/dist/modules/n8n-packages/n8n-packages.controller.js +45 -0
  420. package/dist/modules/n8n-packages/n8n-packages.controller.js.map +1 -0
  421. package/dist/modules/{inbound-secrets/inbound-secrets.module.d.ts → n8n-packages/n8n-packages.module.d.ts} +1 -1
  422. package/dist/modules/{inbound-secrets/inbound-secrets.module.js → n8n-packages/n8n-packages.module.js} +12 -16
  423. package/dist/modules/n8n-packages/n8n-packages.module.js.map +1 -0
  424. package/dist/modules/n8n-packages/n8n-packages.service.d.ts +10 -0
  425. package/dist/modules/n8n-packages/n8n-packages.service.js +49 -0
  426. package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -0
  427. package/dist/modules/n8n-packages/n8n-packages.types.d.ts +5 -0
  428. package/dist/modules/n8n-packages/n8n-packages.types.js +3 -0
  429. package/dist/modules/n8n-packages/n8n-packages.types.js.map +1 -0
  430. package/dist/modules/n8n-packages/spec/constants.d.ts +1 -0
  431. package/dist/modules/n8n-packages/spec/constants.js +5 -0
  432. package/dist/modules/n8n-packages/spec/constants.js.map +1 -0
  433. package/dist/modules/n8n-packages/spec/manifest.schema.d.ts +55 -0
  434. package/dist/modules/n8n-packages/spec/manifest.schema.js +17 -0
  435. package/dist/modules/n8n-packages/spec/manifest.schema.js.map +1 -0
  436. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.d.ts +169 -0
  437. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js +46 -0
  438. package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js.map +1 -0
  439. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.d.ts +5 -1
  440. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js +18 -2
  441. package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js.map +1 -1
  442. package/dist/modules/oauth-jwe/oauth-jwe.utils.js +27 -2
  443. package/dist/modules/oauth-jwe/oauth-jwe.utils.js.map +1 -1
  444. package/dist/modules/otel/execution-level-tracer.js +1 -0
  445. package/dist/modules/otel/execution-level-tracer.js.map +1 -1
  446. package/dist/modules/otel/execution-level-tracer.types.d.ts +11 -6
  447. package/dist/modules/otel/execution-level-tracer.types.js.map +1 -1
  448. package/dist/modules/otel/otel-lifecycle-handler.d.ts +5 -1
  449. package/dist/modules/otel/otel-lifecycle-handler.js +30 -2
  450. package/dist/modules/otel/otel-lifecycle-handler.js.map +1 -1
  451. package/dist/modules/otel/otel.constants.d.ts +1 -0
  452. package/dist/modules/otel/otel.constants.js +1 -0
  453. package/dist/modules/otel/otel.constants.js.map +1 -1
  454. package/dist/modules/runtime-credentials/path-traversal.js.map +1 -0
  455. package/dist/modules/runtime-credentials/runtime-credentials-access.service.d.ts +8 -0
  456. package/dist/modules/runtime-credentials/runtime-credentials-access.service.js +35 -0
  457. package/dist/modules/runtime-credentials/runtime-credentials-access.service.js.map +1 -0
  458. package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.d.ts → runtime-credentials/runtime-credentials-context-hook.d.ts} +4 -5
  459. package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.js → runtime-credentials/runtime-credentials-context-hook.js} +14 -22
  460. package/dist/modules/runtime-credentials/runtime-credentials-context-hook.js.map +1 -0
  461. package/dist/modules/runtime-credentials/runtime-credentials.config.d.ts +3 -0
  462. package/dist/modules/{inbound-secrets/inbound-secrets.config.js → runtime-credentials/runtime-credentials.config.js} +7 -7
  463. package/dist/modules/runtime-credentials/runtime-credentials.config.js.map +1 -0
  464. package/dist/modules/runtime-credentials/runtime-credentials.module.d.ts +4 -0
  465. package/dist/modules/runtime-credentials/runtime-credentials.module.js +65 -0
  466. package/dist/modules/runtime-credentials/runtime-credentials.module.js.map +1 -0
  467. package/dist/modules/runtime-credentials/runtime-credentials.schemas.d.ts +23 -0
  468. package/dist/modules/runtime-credentials/runtime-credentials.schemas.js +10 -0
  469. package/dist/modules/runtime-credentials/runtime-credentials.schemas.js.map +1 -0
  470. package/dist/modules/runtime-credentials/runtime-credentials.service.d.ts +18 -0
  471. package/dist/modules/{inbound-secrets/inbound-secrets.service.js → runtime-credentials/runtime-credentials.service.js} +31 -28
  472. package/dist/modules/runtime-credentials/runtime-credentials.service.js.map +1 -0
  473. package/dist/modules/source-control.ee/source-control-export.service.ee.d.ts +1 -1
  474. package/dist/modules/source-control.ee/source-control-export.service.ee.js +3 -1
  475. package/dist/modules/source-control.ee/source-control-export.service.ee.js.map +1 -1
  476. package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +2 -2
  477. package/dist/modules/source-control.ee/source-control-import.service.ee.js +29 -8
  478. package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
  479. package/dist/modules/source-control.ee/source-control-status.service.ee.js +4 -4
  480. package/dist/modules/source-control.ee/source-control-status.service.ee.js.map +1 -1
  481. package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +2 -2
  482. package/dist/modules/source-control.ee/source-control.service.ee.d.ts +1 -1
  483. package/dist/modules/source-control.ee/types/exportable-workflow.d.ts +2 -1
  484. package/dist/modules/sso-saml/saml.service.ee.js +5 -1
  485. package/dist/modules/sso-saml/saml.service.ee.js.map +1 -1
  486. package/dist/modules/workflow-index/workflow-dependency.controller.d.ts +1 -4
  487. package/dist/modules/workflow-index/workflow-dependency.controller.js +2 -13
  488. package/dist/modules/workflow-index/workflow-dependency.controller.js.map +1 -1
  489. package/dist/node-catalog/node-catalog.service.d.ts +1 -2
  490. package/dist/node-catalog/node-catalog.service.js +6 -10
  491. package/dist/node-catalog/node-catalog.service.js.map +1 -1
  492. package/dist/node-execution/ephemeral-node-executor.js +19 -11
  493. package/dist/node-execution/ephemeral-node-executor.js.map +1 -1
  494. package/dist/oauth/oauth-jwe-service.proxy.d.ts +12 -2
  495. package/dist/oauth/oauth-jwe-service.proxy.js +5 -0
  496. package/dist/oauth/oauth-jwe-service.proxy.js.map +1 -1
  497. package/dist/oauth/oauth.service.d.ts +6 -1
  498. package/dist/oauth/oauth.service.js +42 -4
  499. package/dist/oauth/oauth.service.js.map +1 -1
  500. package/dist/permissions.ee/check-access.d.ts +2 -2
  501. package/dist/permissions.ee/check-access.js +15 -11
  502. package/dist/permissions.ee/check-access.js.map +1 -1
  503. package/dist/posthog/index.d.ts +2 -0
  504. package/dist/posthog/index.js +28 -6
  505. package/dist/posthog/index.js.map +1 -1
  506. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.d.ts +10 -0
  507. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +42 -0
  508. package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -0
  509. package/dist/public-api/v1/openapi.yml +55 -0
  510. package/dist/requests.d.ts +1 -1
  511. package/dist/scaling/constants.js +3 -0
  512. package/dist/scaling/constants.js.map +1 -1
  513. package/dist/scaling/multi-main-setup.ee.d.ts +12 -7
  514. package/dist/scaling/multi-main-setup.ee.js +125 -22
  515. package/dist/scaling/multi-main-setup.ee.js.map +1 -1
  516. package/dist/server.d.ts +1 -0
  517. package/dist/server.js +3 -4
  518. package/dist/server.js.map +1 -1
  519. package/dist/services/dynamic-node-parameters.service.d.ts +0 -1
  520. package/dist/services/dynamic-node-parameters.service.js +6 -14
  521. package/dist/services/dynamic-node-parameters.service.js.map +1 -1
  522. package/dist/services/frontend.service.js +1 -1
  523. package/dist/services/frontend.service.js.map +1 -1
  524. package/dist/services/import.service.js +3 -1
  525. package/dist/services/import.service.js.map +1 -1
  526. package/dist/services/proxy-token-manager.js +2 -13
  527. package/dist/services/proxy-token-manager.js.map +1 -1
  528. package/dist/services/runtime-credential-proxy.service.d.ts +9 -0
  529. package/dist/services/runtime-credential-proxy.service.js +29 -0
  530. package/dist/services/runtime-credential-proxy.service.js.map +1 -0
  531. package/dist/services/url.service.d.ts +1 -0
  532. package/dist/services/url.service.js +3 -0
  533. package/dist/services/url.service.js.map +1 -1
  534. package/dist/telemetry/index.d.ts +4 -1
  535. package/dist/telemetry/index.js +16 -8
  536. package/dist/telemetry/index.js.map +1 -1
  537. package/dist/utils.d.ts +2 -1
  538. package/dist/utils.js +10 -0
  539. package/dist/utils.js.map +1 -1
  540. package/dist/webhooks/live-webhooks.js +2 -2
  541. package/dist/webhooks/live-webhooks.js.map +1 -1
  542. package/dist/webhooks/webhook-helpers.js +1 -1
  543. package/dist/webhooks/webhook-helpers.js.map +1 -1
  544. package/dist/workflow-execute-additional-data.d.ts +3 -1
  545. package/dist/workflow-execute-additional-data.js +26 -3
  546. package/dist/workflow-execute-additional-data.js.map +1 -1
  547. package/dist/workflow-helpers.d.ts +3 -1
  548. package/dist/workflow-helpers.js +39 -5
  549. package/dist/workflow-helpers.js.map +1 -1
  550. package/dist/workflow-hook-context.service.d.ts +6 -0
  551. package/dist/workflow-hook-context.service.js +32 -0
  552. package/dist/workflow-hook-context.service.js.map +1 -0
  553. package/dist/workflow-runner.js +2 -1
  554. package/dist/workflow-runner.js.map +1 -1
  555. package/dist/workflows/utils.d.ts +3 -0
  556. package/dist/workflows/utils.js +19 -0
  557. package/dist/workflows/utils.js.map +1 -1
  558. package/dist/workflows/workflow-creation.service.js +4 -2
  559. package/dist/workflows/workflow-creation.service.js.map +1 -1
  560. package/dist/workflows/workflow-execution.service.d.ts +4 -3
  561. package/dist/workflows/workflow-execution.service.js +8 -3
  562. package/dist/workflows/workflow-execution.service.js.map +1 -1
  563. package/dist/workflows/workflow-finder.service.d.ts +6 -2
  564. package/dist/workflows/workflow-finder.service.js +18 -0
  565. package/dist/workflows/workflow-finder.service.js.map +1 -1
  566. package/dist/workflows/workflow-history/workflow-history.controller.d.ts +1 -1
  567. package/dist/workflows/workflow-history/workflow-history.service.d.ts +2 -1
  568. package/dist/workflows/workflow-history/workflow-history.service.js +1 -0
  569. package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
  570. package/dist/workflows/workflow-validation.service.d.ts +3 -1
  571. package/dist/workflows/workflow-validation.service.js +6 -3
  572. package/dist/workflows/workflow-validation.service.js.map +1 -1
  573. package/dist/workflows/workflow.service.d.ts +3 -3
  574. package/dist/workflows/workflow.service.js +26 -4
  575. package/dist/workflows/workflow.service.js.map +1 -1
  576. package/dist/workflows/workflows.controller.d.ts +31 -21
  577. package/dist/workflows/workflows.controller.js +6 -2
  578. package/dist/workflows/workflows.controller.js.map +1 -1
  579. package/package.json +36 -34
  580. package/dist/modules/agents/entities/agent-published-version.entity.js.map +0 -1
  581. package/dist/modules/agents/repositories/agent-published-version.repository.d.ts +0 -20
  582. package/dist/modules/agents/repositories/agent-published-version.repository.js.map +0 -1
  583. package/dist/modules/inbound-secrets/inbound-secrets-context-hook.js.map +0 -1
  584. package/dist/modules/inbound-secrets/inbound-secrets.config.d.ts +0 -3
  585. package/dist/modules/inbound-secrets/inbound-secrets.config.js.map +0 -1
  586. package/dist/modules/inbound-secrets/inbound-secrets.module.js.map +0 -1
  587. package/dist/modules/inbound-secrets/inbound-secrets.schemas.d.ts +0 -3
  588. package/dist/modules/inbound-secrets/inbound-secrets.schemas.js +0 -6
  589. package/dist/modules/inbound-secrets/inbound-secrets.schemas.js.map +0 -1
  590. package/dist/modules/inbound-secrets/inbound-secrets.service.d.ts +0 -17
  591. package/dist/modules/inbound-secrets/inbound-secrets.service.js.map +0 -1
  592. package/dist/modules/inbound-secrets/path-traversal.js.map +0 -1
  593. package/dist/modules/instance-ai/compaction.service.d.ts +0 -24
  594. package/dist/modules/instance-ai/compaction.service.js +0 -213
  595. package/dist/modules/instance-ai/compaction.service.js.map +0 -1
  596. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.d.ts +0 -33
  597. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js +0 -145
  598. package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js.map +0 -1
  599. package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.d.ts +0 -8
  600. package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.js.map +0 -1
  601. package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.d.ts +0 -5
  602. package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.js.map +0 -1
  603. package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.d.ts +0 -5
  604. package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.js.map +0 -1
  605. package/dist/modules/instance-ai/snapshot-pruning.service.d.ts +0 -17
  606. package/dist/modules/instance-ai/snapshot-pruning.service.js +0 -89
  607. package/dist/modules/instance-ai/snapshot-pruning.service.js.map +0 -1
  608. package/dist/modules/instance-ai/storage/typeorm-composite-store.d.ts +0 -9
  609. package/dist/modules/instance-ai/storage/typeorm-composite-store.js +0 -33
  610. package/dist/modules/instance-ai/storage/typeorm-composite-store.js.map +0 -1
  611. package/dist/modules/instance-ai/storage/typeorm-memory-storage.d.ts +0 -96
  612. package/dist/modules/instance-ai/storage/typeorm-memory-storage.js +0 -864
  613. package/dist/modules/instance-ai/storage/typeorm-memory-storage.js.map +0 -1
  614. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.d.ts +0 -44
  615. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js +0 -156
  616. package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js.map +0 -1
  617. package/dist/scaling/multi-main-setup-legacy.d.ts +0 -25
  618. package/dist/scaling/multi-main-setup-legacy.js +0 -75
  619. package/dist/scaling/multi-main-setup-legacy.js.map +0 -1
  620. package/dist/scaling/multi-main-setup-v2.d.ts +0 -25
  621. package/dist/scaling/multi-main-setup-v2.js +0 -143
  622. package/dist/scaling/multi-main-setup-v2.js.map +0 -1
  623. package/dist/scaling/multi-main-setup.types.d.ts +0 -6
  624. package/dist/scaling/multi-main-setup.types.js.map +0 -1
  625. /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.d.ts +0 -0
  626. /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.js +0 -0
@@ -1,864 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var TypeORMMemoryStorage_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.TypeORMMemoryStorage = void 0;
14
- const node_crypto_1 = require("node:crypto");
15
- const storage_1 = require("@mastra/core/storage");
16
- const di_1 = require("@n8n/di");
17
- const instance_ai_1 = require("@n8n/instance-ai");
18
- const typeorm_1 = require("@n8n/typeorm");
19
- const utils_1 = require("@n8n/utils");
20
- const n8n_workflow_1 = require("n8n-workflow");
21
- const instance_ai_message_repository_1 = require("../repositories/instance-ai-message.repository");
22
- const instance_ai_observational_memory_repository_1 = require("../repositories/instance-ai-observational-memory.repository");
23
- const instance_ai_resource_repository_1 = require("../repositories/instance-ai-resource.repository");
24
- const instance_ai_thread_repository_1 = require("../repositories/instance-ai-thread.repository");
25
- const PATCH_ONLY_METADATA_KEYS = [
26
- 'instanceAiPlannedTasks',
27
- 'instanceAiTasks',
28
- 'instanceAiTerminalOutcomes',
29
- 'instanceAiWorkflowLoop',
30
- ];
31
- function countLines(value) {
32
- return value === '' ? 0 : value.split(/\r?\n/u).length;
33
- }
34
- function buildResourceTraceMetadata(resourceId) {
35
- const separatorIndex = resourceId.indexOf(':');
36
- return {
37
- resource_id: resourceId,
38
- memory_scope: separatorIndex === -1 ? 'user' : 'user-role',
39
- ...(separatorIndex !== -1 && separatorIndex < resourceId.length - 1
40
- ? { memory_role: resourceId.slice(separatorIndex + 1) }
41
- : {}),
42
- };
43
- }
44
- function summarizeLoadedResource(resource) {
45
- const workingMemory = resource?.workingMemory;
46
- return {
47
- found: resource !== null,
48
- has_working_memory: typeof workingMemory === 'string' && workingMemory.length > 0,
49
- working_memory_chars: typeof workingMemory === 'string' ? workingMemory.length : 0,
50
- working_memory_lines: typeof workingMemory === 'string' ? countLines(workingMemory) : 0,
51
- metadata_keys: resource?.metadata ? Object.keys(resource.metadata).length : 0,
52
- };
53
- }
54
- let TypeORMMemoryStorage = TypeORMMemoryStorage_1 = class TypeORMMemoryStorage extends storage_1.MemoryStorage {
55
- constructor(threadRepo, messageRepo, resourceRepo, omRepo) {
56
- super();
57
- this.threadRepo = threadRepo;
58
- this.messageRepo = messageRepo;
59
- this.resourceRepo = resourceRepo;
60
- this.omRepo = omRepo;
61
- this.supportsObservationalMemory = true;
62
- }
63
- async dangerouslyClearAll() {
64
- await this.omRepo.clear();
65
- await this.messageRepo.clear();
66
- await this.threadRepo.clear();
67
- await this.resourceRepo.clear();
68
- }
69
- async getThreadById({ threadId }) {
70
- const entity = await this.threadRepo.findOneBy({ id: threadId });
71
- if (!entity)
72
- return null;
73
- return this.toStorageThread(entity);
74
- }
75
- async listThreads(args) {
76
- const page = args.page ?? 0;
77
- const perPageInput = args.perPage;
78
- const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 100);
79
- const { field, direction } = this.parseOrderBy(args.orderBy);
80
- const where = {};
81
- if (args.filter?.resourceId)
82
- where.resourceId = args.filter.resourceId;
83
- const metadataFilter = args.filter?.metadata;
84
- const hasMetadataFilter = metadataFilter && Object.keys(metadataFilter).length > 0;
85
- if (hasMetadataFilter) {
86
- this.validateMetadataKeys(metadataFilter);
87
- const allEntities = await this.threadRepo.find({
88
- where,
89
- order: { [field]: direction },
90
- });
91
- const allThreads = allEntities
92
- .map((e) => ({
93
- id: e.id,
94
- title: e.title,
95
- resourceId: e.resourceId,
96
- metadata: e.metadata ?? undefined,
97
- createdAt: e.createdAt,
98
- updatedAt: e.updatedAt,
99
- }))
100
- .filter((t) => {
101
- if (!t.metadata)
102
- return false;
103
- return Object.entries(args.filter.metadata).every(([k, v]) => t.metadata[k] === v);
104
- });
105
- const total = allThreads.length;
106
- const offset = page * perPage;
107
- const paged = allThreads.slice(offset, offset + perPage);
108
- return {
109
- threads: paged,
110
- total,
111
- page,
112
- perPage: perPageInput ?? 100,
113
- hasMore: offset + perPage < total,
114
- };
115
- }
116
- const [entities, total] = await this.threadRepo.findAndCount({
117
- where,
118
- order: { [field]: direction },
119
- skip: page * perPage,
120
- take: perPage,
121
- });
122
- const threads = entities.map((e) => ({
123
- id: e.id,
124
- title: e.title,
125
- resourceId: e.resourceId,
126
- metadata: e.metadata ?? undefined,
127
- createdAt: e.createdAt,
128
- updatedAt: e.updatedAt,
129
- }));
130
- return {
131
- threads,
132
- total,
133
- page,
134
- perPage: perPageInput ?? 100,
135
- hasMore: (page + 1) * perPage < total,
136
- };
137
- }
138
- async saveThread({ thread, }) {
139
- return await this.serializeThreadMutation(thread.id, async () => {
140
- const existing = await this.threadRepo.findOneBy({ id: thread.id });
141
- if (existing) {
142
- const safeIncoming = { ...(thread.metadata ?? {}) };
143
- for (const key of PATCH_ONLY_METADATA_KEYS) {
144
- delete safeIncoming[key];
145
- }
146
- existing.title = thread.title ?? existing.title;
147
- existing.resourceId = thread.resourceId ?? existing.resourceId;
148
- existing.metadata = {
149
- ...(existing.metadata ?? {}),
150
- ...safeIncoming,
151
- };
152
- const saved = await this.threadRepo.save(existing);
153
- return this.toStorageThread(saved);
154
- }
155
- const entity = this.threadRepo.create({
156
- id: thread.id,
157
- resourceId: thread.resourceId,
158
- title: thread.title ?? '',
159
- metadata: thread.metadata ?? null,
160
- });
161
- const saved = await this.threadRepo.save(entity);
162
- return this.toStorageThread(saved);
163
- });
164
- }
165
- async updateThread({ id, title, metadata, }) {
166
- return await this.serializeThreadMutation(id, async () => {
167
- const entity = await this.threadRepo.findOneByOrFail({ id });
168
- const safeIncoming = { ...metadata };
169
- for (const key of PATCH_ONLY_METADATA_KEYS) {
170
- delete safeIncoming[key];
171
- }
172
- entity.title = title;
173
- entity.metadata = {
174
- ...(entity.metadata ?? {}),
175
- ...safeIncoming,
176
- };
177
- const updated = await this.threadRepo.save(entity);
178
- return this.toStorageThread(updated);
179
- });
180
- }
181
- async patchThread({ threadId, update, }) {
182
- return await this.serializeThreadMutation(threadId, async () => {
183
- const entity = await this.threadRepo.findOneBy({ id: threadId });
184
- if (!entity)
185
- return null;
186
- const current = this.toStorageThread(entity);
187
- const patch = update({
188
- ...current,
189
- metadata: { ...(current.metadata ?? {}) },
190
- });
191
- if (!patch)
192
- return current;
193
- if (patch.title !== undefined) {
194
- entity.title = patch.title;
195
- }
196
- if (patch.metadata !== undefined) {
197
- entity.metadata = patch.metadata;
198
- }
199
- const updated = await this.threadRepo.save(entity);
200
- return this.toStorageThread(updated);
201
- });
202
- }
203
- async deleteThread({ threadId }) {
204
- await this.threadRepo.delete(threadId);
205
- }
206
- toStorageThread(entity) {
207
- return {
208
- id: entity.id,
209
- title: entity.title,
210
- resourceId: entity.resourceId,
211
- metadata: entity.metadata ?? undefined,
212
- createdAt: entity.createdAt,
213
- updatedAt: entity.updatedAt,
214
- };
215
- }
216
- async serializeThreadMutation(threadId, mutation) {
217
- const queues = TypeORMMemoryStorage_1.threadMutationQueues;
218
- const previous = queues.get(threadId) ?? Promise.resolve();
219
- const previousSettled = previous.catch(() => { });
220
- let releaseCurrent;
221
- const current = new Promise((resolve) => {
222
- releaseCurrent = resolve;
223
- });
224
- const queued = previousSettled.then(async () => await current);
225
- queues.set(threadId, queued);
226
- await previousSettled;
227
- try {
228
- return await mutation();
229
- }
230
- finally {
231
- releaseCurrent();
232
- if (queues.get(threadId) === queued) {
233
- queues.delete(threadId);
234
- }
235
- }
236
- }
237
- async listMessages(args) {
238
- if (args.include?.length) {
239
- const included = await this.getIncludedMessages(args);
240
- return {
241
- messages: included,
242
- total: included.length,
243
- page: 0,
244
- perPage: false,
245
- hasMore: false,
246
- };
247
- }
248
- const threadIds = Array.isArray(args.threadId) ? args.threadId : [args.threadId];
249
- const page = args.page ?? 0;
250
- const perPageInput = args.perPage;
251
- const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 40);
252
- const qb = this.messageRepo
253
- .createQueryBuilder('m')
254
- .where('m.threadId IN (:...threadIds)', { threadIds });
255
- if (args.resourceId) {
256
- qb.andWhere('m.resourceId = :resourceId', {
257
- resourceId: args.resourceId,
258
- });
259
- }
260
- if (args.filter?.dateRange?.start) {
261
- const op = args.filter.dateRange.startExclusive ? '>' : '>=';
262
- qb.andWhere(`m.createdAt ${op} :start`, {
263
- start: args.filter.dateRange.start,
264
- });
265
- }
266
- if (args.filter?.dateRange?.end) {
267
- const op = args.filter.dateRange.endExclusive ? '<' : '<=';
268
- qb.andWhere(`m.createdAt ${op} :end`, {
269
- end: args.filter.dateRange.end,
270
- });
271
- }
272
- const { field = 'createdAt', direction = 'ASC' } = args.orderBy ?? {};
273
- qb.orderBy(`m.${field}`, direction);
274
- const total = await qb.getCount();
275
- qb.skip(page * perPage).take(perPage);
276
- const entities = await qb.getMany();
277
- const messages = entities.map((e) => this.entityToMessage(e));
278
- return {
279
- messages,
280
- total,
281
- page,
282
- perPage: perPageInput ?? 40,
283
- hasMore: (page + 1) * perPage < total,
284
- };
285
- }
286
- async getIncludedMessages(args) {
287
- const seen = new Set();
288
- const result = [];
289
- const threadIds = Array.isArray(args.threadId) ? args.threadId : [args.threadId];
290
- for (const inc of args.include ?? []) {
291
- const anchorThreadIds = inc.threadId ? [inc.threadId] : threadIds;
292
- const anchor = await this.messageRepo.findOneBy({ id: inc.id });
293
- if (!anchor)
294
- continue;
295
- const collected = [];
296
- if (inc.withPreviousMessages && inc.withPreviousMessages > 0) {
297
- const before = await this.messageRepo
298
- .createQueryBuilder('m')
299
- .where('m.threadId IN (:...threadIds)', { threadIds: anchorThreadIds })
300
- .andWhere('m.createdAt < :anchorTime', { anchorTime: anchor.createdAt })
301
- .orderBy('m.createdAt', 'DESC')
302
- .take(inc.withPreviousMessages)
303
- .getMany();
304
- collected.push(...before.reverse().map((e) => this.entityToMessage(e)));
305
- }
306
- collected.push(this.entityToMessage(anchor));
307
- if (inc.withNextMessages && inc.withNextMessages > 0) {
308
- const after = await this.messageRepo
309
- .createQueryBuilder('m')
310
- .where('m.threadId IN (:...threadIds)', { threadIds: anchorThreadIds })
311
- .andWhere('m.createdAt > :anchorTime', { anchorTime: anchor.createdAt })
312
- .orderBy('m.createdAt', 'ASC')
313
- .take(inc.withNextMessages)
314
- .getMany();
315
- collected.push(...after.map((e) => this.entityToMessage(e)));
316
- }
317
- for (const msg of collected) {
318
- if (!seen.has(msg.id)) {
319
- seen.add(msg.id);
320
- result.push(msg);
321
- }
322
- }
323
- }
324
- result.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
325
- return result;
326
- }
327
- async listMessagesByResourceId(args) {
328
- const page = args.page ?? 0;
329
- const perPageInput = args.perPage;
330
- const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 40);
331
- const qb = this.messageRepo
332
- .createQueryBuilder('m')
333
- .where('m.resourceId = :resourceId', { resourceId: args.resourceId });
334
- if (args.filter?.dateRange?.start) {
335
- const op = args.filter.dateRange.startExclusive ? '>' : '>=';
336
- qb.andWhere(`m.createdAt ${op} :start`, {
337
- start: args.filter.dateRange.start,
338
- });
339
- }
340
- if (args.filter?.dateRange?.end) {
341
- const op = args.filter.dateRange.endExclusive ? '<' : '<=';
342
- qb.andWhere(`m.createdAt ${op} :end`, {
343
- end: args.filter.dateRange.end,
344
- });
345
- }
346
- const { field = 'createdAt', direction = 'ASC' } = args.orderBy ?? {};
347
- qb.orderBy(`m.${field}`, direction);
348
- const total = await qb.getCount();
349
- qb.skip(page * perPage).take(perPage);
350
- const entities = await qb.getMany();
351
- return {
352
- messages: entities.map((e) => this.entityToMessage(e)),
353
- total,
354
- page,
355
- perPage: perPageInput ?? 40,
356
- hasMore: (page + 1) * perPage < total,
357
- };
358
- }
359
- async listMessagesById({ messageIds, }) {
360
- if (messageIds.length === 0)
361
- return { messages: [] };
362
- const entities = await this.messageRepo.findBy({ id: (0, typeorm_1.In)(messageIds) });
363
- return { messages: entities.map((e) => this.entityToMessage(e)) };
364
- }
365
- async saveMessages({ messages, }) {
366
- const entities = messages.map((m) => {
367
- if (!m.threadId) {
368
- throw new Error(`Message ${m.id} is missing required threadId`);
369
- }
370
- const entity = this.messageRepo.create({
371
- id: m.id,
372
- threadId: m.threadId,
373
- content: JSON.stringify(m.content),
374
- role: m.role,
375
- type: m.type ?? null,
376
- resourceId: m.resourceId ?? null,
377
- });
378
- if (m.createdAt) {
379
- entity.createdAt = m.createdAt;
380
- }
381
- return entity;
382
- });
383
- const saved = await this.messageRepo.save(entities);
384
- const threadIds = [
385
- ...new Set(messages.map((m) => m.threadId).filter((id) => !!id)),
386
- ];
387
- if (threadIds.length > 0) {
388
- await this.threadRepo.update(threadIds, { updatedAt: new Date() });
389
- }
390
- return { messages: saved.map((e) => this.entityToMessage(e)) };
391
- }
392
- async updateMessages({ messages, }) {
393
- const result = [];
394
- for (const msg of messages) {
395
- const existing = await this.messageRepo.findOneBy({ id: msg.id });
396
- if (!existing)
397
- continue;
398
- const updates = {};
399
- if (msg.role)
400
- updates.role = msg.role;
401
- if (msg.type !== undefined)
402
- updates.type = msg.type;
403
- if (msg.content) {
404
- const existingContent = (0, n8n_workflow_1.jsonParse)(existing.content);
405
- if (msg.content.metadata !== undefined)
406
- existingContent.metadata = msg.content.metadata;
407
- if (msg.content.content !== undefined)
408
- existingContent.content = msg.content.content;
409
- updates.content = JSON.stringify(existingContent);
410
- }
411
- if (Object.keys(updates).length > 0) {
412
- await this.messageRepo.update(msg.id, updates);
413
- }
414
- const updated = await this.messageRepo.findOneByOrFail({ id: msg.id });
415
- result.push(this.entityToMessage(updated));
416
- }
417
- return result;
418
- }
419
- async deleteMessages(messageIds) {
420
- if (messageIds.length === 0)
421
- return;
422
- await this.messageRepo.delete(messageIds);
423
- }
424
- async getResourceById({ resourceId, }) {
425
- return await (0, instance_ai_1.withCurrentTraceSpan)({
426
- name: 'memory_load',
427
- tags: ['memory', 'internal'],
428
- metadata: buildResourceTraceMetadata(resourceId),
429
- inputs: { resource_id: resourceId },
430
- processOutputs: summarizeLoadedResource,
431
- }, async () => {
432
- const entity = await this.resourceRepo.findOneBy({ id: resourceId });
433
- if (!entity)
434
- return null;
435
- return {
436
- id: entity.id,
437
- workingMemory: entity.workingMemory ?? undefined,
438
- metadata: entity.metadata ?? undefined,
439
- createdAt: entity.createdAt,
440
- updatedAt: entity.updatedAt,
441
- };
442
- });
443
- }
444
- async saveResource({ resource, }) {
445
- const entity = this.resourceRepo.create({
446
- id: resource.id,
447
- workingMemory: resource.workingMemory ?? null,
448
- metadata: resource.metadata ?? null,
449
- });
450
- const saved = await this.resourceRepo.save(entity);
451
- return {
452
- id: saved.id,
453
- workingMemory: saved.workingMemory ?? undefined,
454
- metadata: saved.metadata ?? undefined,
455
- createdAt: saved.createdAt,
456
- updatedAt: saved.updatedAt,
457
- };
458
- }
459
- async updateResource({ resourceId, workingMemory, metadata, }) {
460
- let existing = await this.resourceRepo.findOneBy({ id: resourceId });
461
- if (!existing) {
462
- existing = await this.resourceRepo.save(this.resourceRepo.create({
463
- id: resourceId,
464
- workingMemory: workingMemory ?? null,
465
- metadata: metadata ?? null,
466
- }));
467
- }
468
- else {
469
- if (workingMemory !== undefined)
470
- existing.workingMemory = workingMemory;
471
- if (metadata !== undefined)
472
- existing.metadata = metadata;
473
- existing = await this.resourceRepo.save(existing);
474
- }
475
- return {
476
- id: existing.id,
477
- workingMemory: existing.workingMemory ?? undefined,
478
- metadata: existing.metadata ?? undefined,
479
- createdAt: existing.createdAt,
480
- updatedAt: existing.updatedAt,
481
- };
482
- }
483
- async cloneThread(args) {
484
- const source = await this.getThreadById({
485
- threadId: args.sourceThreadId,
486
- });
487
- if (!source)
488
- throw new Error(`Source thread ${args.sourceThreadId} not found`);
489
- const newThreadId = args.newThreadId ?? (0, node_crypto_1.randomUUID)();
490
- const cloneMetadata = {
491
- ...(source.metadata ?? {}),
492
- ...(args.metadata ?? {}),
493
- mastra: {
494
- ...(source.metadata?.mastra ?? {}),
495
- clone: {
496
- sourceThreadId: args.sourceThreadId,
497
- clonedAt: new Date(),
498
- },
499
- },
500
- };
501
- const newThread = await this.saveThread({
502
- thread: {
503
- id: newThreadId,
504
- resourceId: args.resourceId ?? source.resourceId,
505
- title: args.title ?? source.title,
506
- metadata: cloneMetadata,
507
- createdAt: new Date(),
508
- updatedAt: new Date(),
509
- },
510
- });
511
- const { messages: sourceMessages } = await this.listMessages({
512
- threadId: args.sourceThreadId,
513
- perPage: false,
514
- orderBy: { field: 'createdAt', direction: 'ASC' },
515
- });
516
- let messagesToClone = sourceMessages;
517
- if (args.options?.messageLimit) {
518
- messagesToClone = messagesToClone.slice(-args.options.messageLimit);
519
- }
520
- const messageIdMap = {};
521
- const clonedMessages = messagesToClone.map((m) => {
522
- const newId = (0, utils_1.generateNanoId)();
523
- messageIdMap[m.id] = newId;
524
- return { ...m, id: newId, threadId: newThreadId };
525
- });
526
- if (clonedMessages.length > 0) {
527
- await this.saveMessages({ messages: clonedMessages });
528
- }
529
- return { thread: newThread, clonedMessages, messageIdMap };
530
- }
531
- omLookupKey(scope, threadId, resourceId) {
532
- return `${scope}:${threadId ?? 'null'}:${resourceId}`;
533
- }
534
- entityToOMRecord(entity) {
535
- return {
536
- id: entity.id,
537
- scope: entity.scope,
538
- threadId: entity.threadId,
539
- resourceId: entity.resourceId,
540
- createdAt: entity.createdAt,
541
- updatedAt: entity.updatedAt,
542
- lastObservedAt: entity.lastObservedAt ?? undefined,
543
- originType: entity.originType,
544
- generationCount: entity.generationCount,
545
- activeObservations: entity.activeObservations,
546
- bufferedObservationChunks: (entity.bufferedObservationChunks ??
547
- undefined),
548
- bufferedObservations: entity.bufferedObservations ?? undefined,
549
- bufferedObservationTokens: entity.bufferedObservationTokens ?? undefined,
550
- bufferedMessageIds: entity.bufferedMessageIds ?? undefined,
551
- bufferedReflection: entity.bufferedReflection ?? undefined,
552
- bufferedReflectionTokens: entity.bufferedReflectionTokens ?? undefined,
553
- bufferedReflectionInputTokens: entity.bufferedReflectionInputTokens ?? undefined,
554
- reflectedObservationLineCount: entity.reflectedObservationLineCount ?? undefined,
555
- observedMessageIds: entity.observedMessageIds ?? undefined,
556
- observedTimezone: entity.observedTimezone ?? undefined,
557
- totalTokensObserved: entity.totalTokensObserved,
558
- observationTokenCount: entity.observationTokenCount,
559
- pendingMessageTokens: entity.pendingMessageTokens,
560
- isReflecting: entity.isReflecting,
561
- isObserving: entity.isObserving,
562
- isBufferingObservation: entity.isBufferingObservation,
563
- isBufferingReflection: entity.isBufferingReflection,
564
- lastBufferedAtTokens: entity.lastBufferedAtTokens,
565
- lastBufferedAtTime: entity.lastBufferedAtTime,
566
- config: typeof entity.config === 'string' ? (0, n8n_workflow_1.jsonParse)(entity.config) : entity.config,
567
- metadata: entity.metadata ?? undefined,
568
- };
569
- }
570
- async getObservationalMemory(threadId, resourceId) {
571
- const lookupKey = this.omLookupKey(threadId ? 'thread' : 'resource', threadId, resourceId);
572
- const entity = await this.omRepo.findOne({
573
- where: { lookupKey },
574
- order: { generationCount: 'DESC' },
575
- });
576
- if (!entity)
577
- return null;
578
- return this.entityToOMRecord(entity);
579
- }
580
- async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
581
- const scope = threadId ? 'thread' : 'resource';
582
- const entities = await this.omRepo.find({
583
- where: { scope, threadId: threadId ?? undefined, resourceId },
584
- order: { generationCount: 'DESC' },
585
- take: limit,
586
- });
587
- return entities.map((e) => this.entityToOMRecord(e));
588
- }
589
- async initializeObservationalMemory(input) {
590
- const id = (0, utils_1.generateNanoId)();
591
- const lookupKey = this.omLookupKey(input.scope, input.threadId, input.resourceId);
592
- const entity = this.omRepo.create({
593
- id,
594
- lookupKey,
595
- scope: input.scope,
596
- threadId: input.threadId,
597
- resourceId: input.resourceId,
598
- originType: 'initial',
599
- config: JSON.stringify(input.config),
600
- observedTimezone: input.observedTimezone ?? null,
601
- });
602
- const saved = await this.omRepo.save(entity);
603
- return this.entityToOMRecord(saved);
604
- }
605
- async insertObservationalMemoryRecord(record) {
606
- const lookupKey = this.omLookupKey(record.scope, record.threadId, record.resourceId);
607
- const entity = this.omRepo.create({
608
- id: record.id,
609
- lookupKey,
610
- scope: record.scope,
611
- threadId: record.threadId,
612
- resourceId: record.resourceId,
613
- activeObservations: record.activeObservations,
614
- originType: record.originType,
615
- config: JSON.stringify(record.config),
616
- generationCount: record.generationCount,
617
- lastObservedAt: record.lastObservedAt ?? null,
618
- pendingMessageTokens: record.pendingMessageTokens,
619
- totalTokensObserved: record.totalTokensObserved,
620
- observationTokenCount: record.observationTokenCount,
621
- isObserving: record.isObserving,
622
- isReflecting: record.isReflecting,
623
- observedMessageIds: record.observedMessageIds ?? null,
624
- observedTimezone: record.observedTimezone ?? null,
625
- bufferedObservations: record.bufferedObservations ?? null,
626
- bufferedObservationTokens: record.bufferedObservationTokens ?? null,
627
- bufferedMessageIds: record.bufferedMessageIds ?? null,
628
- bufferedReflection: record.bufferedReflection ?? null,
629
- bufferedReflectionTokens: record.bufferedReflectionTokens ?? null,
630
- bufferedReflectionInputTokens: record.bufferedReflectionInputTokens ?? null,
631
- reflectedObservationLineCount: record.reflectedObservationLineCount ?? null,
632
- bufferedObservationChunks: (record.bufferedObservationChunks ?? null),
633
- isBufferingObservation: record.isBufferingObservation,
634
- isBufferingReflection: record.isBufferingReflection,
635
- lastBufferedAtTokens: record.lastBufferedAtTokens,
636
- lastBufferedAtTime: record.lastBufferedAtTime ?? null,
637
- metadata: record.metadata ?? null,
638
- });
639
- await this.omRepo.save(entity);
640
- }
641
- async updateActiveObservations(input) {
642
- const entity = await this.omRepo.findOneByOrFail({ id: input.id });
643
- const existingIds = entity.observedMessageIds ?? [];
644
- const mergedIds = [...new Set([...existingIds, ...(input.observedMessageIds ?? [])])];
645
- await this.omRepo.update(input.id, {
646
- activeObservations: input.observations,
647
- observationTokenCount: input.tokenCount,
648
- lastObservedAt: input.lastObservedAt,
649
- observedMessageIds: mergedIds,
650
- observedTimezone: input.observedTimezone ?? entity.observedTimezone,
651
- totalTokensObserved: entity.totalTokensObserved + input.tokenCount,
652
- });
653
- }
654
- async updateBufferedObservations(input) {
655
- const entity = await this.omRepo.findOneByOrFail({ id: input.id });
656
- const chunks = entity.bufferedObservationChunks ?? [];
657
- chunks.push(input.chunk);
658
- const updates = {
659
- bufferedObservationChunks: chunks,
660
- };
661
- if (input.lastBufferedAtTime) {
662
- updates.lastBufferedAtTime = input.lastBufferedAtTime;
663
- }
664
- await this.omRepo.update(input.id, updates);
665
- }
666
- async swapBufferedToActive(input) {
667
- const entity = await this.omRepo.findOneByOrFail({ id: input.id });
668
- const record = this.entityToOMRecord(entity);
669
- const chunks = record.bufferedObservationChunks ?? [];
670
- if (chunks.length === 0) {
671
- return {
672
- chunksActivated: 0,
673
- messageTokensActivated: 0,
674
- observationTokensActivated: 0,
675
- messagesActivated: 0,
676
- activatedCycleIds: [],
677
- activatedMessageIds: [],
678
- };
679
- }
680
- const retentionFloor = input.messageTokensThreshold * (1 - input.activationRatio);
681
- const tokensToRemove = input.currentPendingTokens - retentionFloor;
682
- let removedTokens = 0;
683
- let activatedCount = 0;
684
- const activated = [];
685
- const remaining = [];
686
- for (const chunk of chunks) {
687
- if (removedTokens < tokensToRemove || (input.forceMaxActivation && remaining.length === 0)) {
688
- activated.push(chunk);
689
- removedTokens += chunk.messageTokens ?? 0;
690
- activatedCount++;
691
- }
692
- else {
693
- remaining.push(chunk);
694
- }
695
- }
696
- let totalMessageTokens = 0;
697
- let totalObsTokens = 0;
698
- let totalMessages = 0;
699
- const allMsgIds = [];
700
- const cycleIds = [];
701
- const observationParts = [];
702
- for (const chunk of activated) {
703
- totalMessageTokens += chunk.messageTokens ?? 0;
704
- totalObsTokens += chunk.tokenCount ?? 0;
705
- totalMessages += chunk.messageIds?.length ?? 0;
706
- allMsgIds.push(...(chunk.messageIds ?? []));
707
- if (chunk.cycleId)
708
- cycleIds.push(chunk.cycleId);
709
- if (chunk.observations)
710
- observationParts.push(chunk.observations);
711
- }
712
- const newActive = record.activeObservations
713
- ? record.activeObservations + '\n' + observationParts.join('\n')
714
- : observationParts.join('\n');
715
- const lastActivatedChunk = activated[activated.length - 1];
716
- const newLastObservedAt = input.lastObservedAt ??
717
- (lastActivatedChunk?.lastObservedAt
718
- ? new Date(lastActivatedChunk.lastObservedAt)
719
- : record.lastObservedAt);
720
- const existingMsgIds = record.observedMessageIds ?? [];
721
- const mergedMsgIds = [...new Set([...existingMsgIds, ...allMsgIds])];
722
- await this.omRepo.update(input.id, {
723
- activeObservations: newActive,
724
- observationTokenCount: record.observationTokenCount + totalObsTokens,
725
- bufferedObservationChunks: remaining.length > 0 ? remaining : null,
726
- lastObservedAt: newLastObservedAt ?? null,
727
- observedMessageIds: mergedMsgIds,
728
- totalTokensObserved: record.totalTokensObserved + totalObsTokens,
729
- isBufferingObservation: false,
730
- });
731
- return {
732
- chunksActivated: activatedCount,
733
- messageTokensActivated: totalMessageTokens,
734
- observationTokensActivated: totalObsTokens,
735
- messagesActivated: totalMessages,
736
- activatedCycleIds: cycleIds,
737
- activatedMessageIds: allMsgIds,
738
- observations: observationParts.join('\n'),
739
- };
740
- }
741
- async createReflectionGeneration(input) {
742
- const { currentRecord, reflection, tokenCount } = input;
743
- const newId = (0, utils_1.generateNanoId)();
744
- const lookupKey = this.omLookupKey(currentRecord.scope, currentRecord.threadId, currentRecord.resourceId);
745
- const entity = this.omRepo.create({
746
- id: newId,
747
- lookupKey,
748
- scope: currentRecord.scope,
749
- threadId: currentRecord.threadId,
750
- resourceId: currentRecord.resourceId,
751
- activeObservations: reflection,
752
- originType: 'reflection',
753
- config: JSON.stringify(currentRecord.config),
754
- generationCount: currentRecord.generationCount + 1,
755
- lastObservedAt: currentRecord.lastObservedAt ?? null,
756
- observationTokenCount: tokenCount,
757
- totalTokensObserved: currentRecord.totalTokensObserved,
758
- pendingMessageTokens: currentRecord.pendingMessageTokens,
759
- isObserving: false,
760
- isReflecting: false,
761
- isBufferingObservation: false,
762
- isBufferingReflection: false,
763
- lastBufferedAtTokens: 0,
764
- lastBufferedAtTime: null,
765
- observedTimezone: currentRecord.observedTimezone ?? null,
766
- metadata: currentRecord.metadata ?? null,
767
- });
768
- const saved = await this.omRepo.save(entity);
769
- return this.entityToOMRecord(saved);
770
- }
771
- async updateBufferedReflection(input) {
772
- await this.omRepo.update(input.id, {
773
- bufferedReflection: input.reflection,
774
- bufferedReflectionTokens: input.tokenCount,
775
- bufferedReflectionInputTokens: input.inputTokenCount,
776
- reflectedObservationLineCount: input.reflectedObservationLineCount,
777
- });
778
- }
779
- async swapBufferedReflectionToActive(input) {
780
- const { currentRecord, tokenCount } = input;
781
- const lines = currentRecord.activeObservations.split('\n');
782
- const reflectedCount = currentRecord.reflectedObservationLineCount ?? lines.length;
783
- const unreflected = lines.slice(reflectedCount).join('\n');
784
- const newActive = currentRecord.bufferedReflection
785
- ? unreflected
786
- ? `${currentRecord.bufferedReflection}\n${unreflected}`
787
- : currentRecord.bufferedReflection
788
- : unreflected;
789
- const newId = (0, utils_1.generateNanoId)();
790
- const lookupKey = this.omLookupKey(currentRecord.scope, currentRecord.threadId, currentRecord.resourceId);
791
- const entity = this.omRepo.create({
792
- id: newId,
793
- lookupKey,
794
- scope: currentRecord.scope,
795
- threadId: currentRecord.threadId,
796
- resourceId: currentRecord.resourceId,
797
- activeObservations: newActive,
798
- originType: 'reflection',
799
- config: JSON.stringify(currentRecord.config),
800
- generationCount: currentRecord.generationCount + 1,
801
- lastObservedAt: currentRecord.lastObservedAt ?? null,
802
- observationTokenCount: tokenCount,
803
- totalTokensObserved: currentRecord.totalTokensObserved,
804
- pendingMessageTokens: currentRecord.pendingMessageTokens,
805
- isObserving: false,
806
- isReflecting: false,
807
- isBufferingObservation: false,
808
- isBufferingReflection: false,
809
- lastBufferedAtTokens: 0,
810
- lastBufferedAtTime: null,
811
- observedTimezone: currentRecord.observedTimezone ?? null,
812
- metadata: currentRecord.metadata ?? null,
813
- });
814
- const saved = await this.omRepo.save(entity);
815
- return this.entityToOMRecord(saved);
816
- }
817
- async setReflectingFlag(id, isReflecting) {
818
- await this.omRepo.update(id, { isReflecting });
819
- }
820
- async setObservingFlag(id, isObserving) {
821
- await this.omRepo.update(id, { isObserving });
822
- }
823
- async setBufferingObservationFlag(id, isBuffering, lastBufferedAtTokens) {
824
- const updates = {
825
- isBufferingObservation: isBuffering,
826
- };
827
- if (isBuffering && lastBufferedAtTokens !== undefined) {
828
- updates.lastBufferedAtTokens = lastBufferedAtTokens;
829
- }
830
- await this.omRepo.update(id, updates);
831
- }
832
- async setBufferingReflectionFlag(id, isBuffering) {
833
- await this.omRepo.update(id, { isBufferingReflection: isBuffering });
834
- }
835
- async clearObservationalMemory(threadId, resourceId) {
836
- const scope = threadId ? 'thread' : 'resource';
837
- const lookupKey = this.omLookupKey(scope, threadId, resourceId);
838
- await this.omRepo.delete({ lookupKey });
839
- }
840
- async setPendingMessageTokens(id, tokenCount) {
841
- await this.omRepo.update(id, { pendingMessageTokens: tokenCount });
842
- }
843
- entityToMessage(entity) {
844
- return {
845
- id: entity.id,
846
- role: entity.role,
847
- createdAt: entity.createdAt,
848
- threadId: entity.threadId,
849
- resourceId: entity.resourceId ?? undefined,
850
- type: entity.type ?? undefined,
851
- content: (0, n8n_workflow_1.jsonParse)(entity.content),
852
- };
853
- }
854
- };
855
- exports.TypeORMMemoryStorage = TypeORMMemoryStorage;
856
- TypeORMMemoryStorage.threadMutationQueues = new Map();
857
- exports.TypeORMMemoryStorage = TypeORMMemoryStorage = TypeORMMemoryStorage_1 = __decorate([
858
- (0, di_1.Service)(),
859
- __metadata("design:paramtypes", [instance_ai_thread_repository_1.InstanceAiThreadRepository,
860
- instance_ai_message_repository_1.InstanceAiMessageRepository,
861
- instance_ai_resource_repository_1.InstanceAiResourceRepository,
862
- instance_ai_observational_memory_repository_1.InstanceAiObservationalMemoryRepository])
863
- ], TypeORMMemoryStorage);
864
- //# sourceMappingURL=typeorm-memory-storage.js.map