openloops 0.3.4 → 0.4.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 (240) hide show
  1. package/README.md +9 -8
  2. package/dist/clients/llm/llm-client.js +6 -5
  3. package/dist/clients/llm/llm-client.mjs +6 -5
  4. package/dist/clients/llm/llm-types.d.ts +3 -0
  5. package/dist/clients/llm/llm-types.js +15 -0
  6. package/dist/clients/llm/llm-types.mjs +7 -0
  7. package/dist/db/index.d.ts +1 -0
  8. package/dist/db/index.js +3 -1
  9. package/dist/db/index.mjs +1 -0
  10. package/dist/db/indexes/automation-runs.d.ts +2 -0
  11. package/dist/db/indexes/automation-runs.js +33 -0
  12. package/dist/db/indexes/automation-runs.mjs +10 -0
  13. package/dist/db/indexes/automations.d.ts +2 -0
  14. package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
  15. package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
  16. package/dist/db/indexes/index.js +6 -4
  17. package/dist/db/indexes/index.mjs +6 -4
  18. package/dist/db/indexes/revoked-tokens.d.ts +2 -0
  19. package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
  20. package/dist/db/indexes/revoked-tokens.mjs +8 -0
  21. package/dist/db/migrations/automations.d.ts +12 -0
  22. package/dist/db/migrations/automations.js +70 -0
  23. package/dist/db/migrations/automations.mjs +47 -0
  24. package/dist/harness/agent-loop.d.ts +2 -0
  25. package/dist/harness/agent.d.ts +1 -0
  26. package/dist/harness/agent.js +8 -0
  27. package/dist/harness/agent.mjs +8 -0
  28. package/dist/loops/agi/loop.js +2 -1
  29. package/dist/loops/agi/loop.mjs +2 -1
  30. package/dist/loops/agi/skills/reasoning-engine.js +3 -2
  31. package/dist/loops/agi/skills/reasoning-engine.mjs +3 -2
  32. package/dist/loops/shared/skills/fast-responder.js +2 -2
  33. package/dist/loops/shared/skills/fast-responder.mjs +2 -2
  34. package/dist/services/authentication/entities/index.d.ts +1 -0
  35. package/dist/services/authentication/entities/index.js +22 -0
  36. package/dist/services/authentication/entities/index.mjs +1 -0
  37. package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
  38. package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
  39. package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
  40. package/dist/services/authentication/index.d.ts +1 -0
  41. package/dist/services/authentication/index.js +3 -1
  42. package/dist/services/authentication/index.mjs +1 -0
  43. package/dist/services/authentication/module.d.ts +4 -0
  44. package/dist/services/authentication/module.js +16 -2
  45. package/dist/services/authentication/module.mjs +13 -1
  46. package/dist/services/authentication/repositories/index.d.ts +1 -0
  47. package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
  48. package/dist/services/authentication/repositories/index.mjs +1 -0
  49. package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
  50. package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
  51. package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
  52. package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
  53. package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
  54. package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
  55. package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
  56. package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
  57. package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
  58. package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
  59. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
  60. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
  61. package/dist/services/automations/entities/automation.entity.d.ts +38 -0
  62. package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
  63. package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
  64. package/dist/services/automations/entities/index.d.ts +4 -0
  65. package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
  66. package/dist/services/automations/entities/index.mjs +4 -0
  67. package/dist/services/automations/entities/trigger.d.ts +11 -0
  68. package/dist/services/automations/entities/trigger.js +49 -0
  69. package/dist/services/automations/entities/trigger.mjs +26 -0
  70. package/dist/services/automations/index.d.ts +5 -0
  71. package/dist/services/{agentic-jobs → automations}/index.js +9 -7
  72. package/dist/services/automations/index.mjs +5 -0
  73. package/dist/services/automations/module.d.ts +41 -0
  74. package/dist/services/automations/module.js +167 -0
  75. package/dist/services/automations/module.mjs +125 -0
  76. package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
  77. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
  78. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
  79. package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
  80. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
  81. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
  82. package/dist/services/automations/repositories/index.d.ts +2 -0
  83. package/dist/services/automations/repositories/index.js +24 -0
  84. package/dist/services/automations/repositories/index.mjs +2 -0
  85. package/dist/services/automations/runner/automation-runner.d.ts +49 -0
  86. package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
  87. package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
  88. package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.d.ts → automations/use-cases/attach-automation-run-chat.use-case.d.ts} +6 -6
  89. package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.js → automations/use-cases/attach-automation-run-chat.use-case.js} +14 -14
  90. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
  91. package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
  92. package/dist/services/{agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.js → automations/use-cases/claim-due-automations.use-case.js} +32 -43
  93. package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
  94. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
  95. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
  96. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
  97. package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
  98. package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
  99. package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
  100. package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.d.ts → automations/use-cases/delete-automation.use-case.d.ts} +6 -6
  101. package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
  102. package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
  103. package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.d.ts → automations/use-cases/finish-automation-run.use-case.d.ts} +8 -8
  104. package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.js → automations/use-cases/finish-automation-run.use-case.js} +20 -20
  105. package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
  106. package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.d.ts → automations/use-cases/get-automation-by-id.use-case.d.ts} +6 -6
  107. package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.js → automations/use-cases/get-automation-by-id.use-case.js} +13 -13
  108. package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
  109. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
  110. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
  111. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
  112. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.d.ts → automations/use-cases/list-automation-runs-by-automation.use-case.d.ts} +7 -7
  113. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.js → automations/use-cases/list-automation-runs-by-automation.use-case.js} +15 -15
  114. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
  115. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.d.ts → automations/use-cases/list-automation-runs-by-user.use-case.d.ts} +7 -7
  116. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.js → automations/use-cases/list-automation-runs-by-user.use-case.js} +14 -14
  117. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.mjs → automations/use-cases/list-automation-runs-by-user.use-case.mjs} +11 -11
  118. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.d.ts → automations/use-cases/list-automations-by-user.use-case.d.ts} +6 -6
  119. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.js → automations/use-cases/list-automations-by-user.use-case.js} +14 -14
  120. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.mjs → automations/use-cases/list-automations-by-user.use-case.mjs} +11 -11
  121. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.d.ts → automations/use-cases/preview-automation-runs.use-case.d.ts} +1 -1
  122. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.js → automations/use-cases/preview-automation-runs.use-case.js} +8 -8
  123. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.mjs → automations/use-cases/preview-automation-runs.use-case.mjs} +4 -4
  124. package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
  125. package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
  126. package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
  127. package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.d.ts → automations/use-cases/renew-automation-lease.use-case.d.ts} +5 -5
  128. package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.js → automations/use-cases/renew-automation-lease.use-case.js} +15 -15
  129. package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
  130. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
  131. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
  132. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
  133. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
  134. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
  135. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
  136. package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
  137. package/dist/services/{agentic-jobs/use-cases/start-agentic-job-run.use-case.js → automations/use-cases/start-automation-run.use-case.js} +24 -24
  138. package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
  139. package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
  140. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.js → automations/use-cases/sync-automation-run.use-case.js} +23 -23
  141. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.mjs → automations/use-cases/sync-automation-run.use-case.mjs} +21 -21
  142. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.d.ts → automations/use-cases/sync-automation-runs.use-case.d.ts} +5 -5
  143. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.js → automations/use-cases/sync-automation-runs.use-case.js} +16 -16
  144. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.mjs → automations/use-cases/sync-automation-runs.use-case.mjs} +13 -13
  145. package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
  146. package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
  147. package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
  148. package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
  149. package/dist/services/automations/utils/automation-event-error.js +37 -0
  150. package/dist/services/automations/utils/automation-event-error.mjs +14 -0
  151. package/dist/services/automations/utils/automation-fields.d.ts +14 -0
  152. package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
  153. package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
  154. package/dist/services/automations/utils/event-message.d.ts +1 -0
  155. package/dist/services/automations/utils/event-message.js +37 -0
  156. package/dist/services/automations/utils/event-message.mjs +14 -0
  157. package/dist/services/automations/utils/event-token.d.ts +18 -0
  158. package/dist/services/automations/utils/event-token.js +78 -0
  159. package/dist/services/automations/utils/event-token.mjs +43 -0
  160. package/dist/services/automations/utils/open-run.d.ts +14 -0
  161. package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
  162. package/dist/services/automations/utils/open-run.mjs +26 -0
  163. package/dist/services/automations/utils/previous-run.d.ts +4 -0
  164. package/dist/services/automations/utils/previous-run.js +42 -0
  165. package/dist/services/automations/utils/previous-run.mjs +19 -0
  166. package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
  167. package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
  168. package/dist/services/automations/utils/settings.mjs +13 -0
  169. package/dist/services/chats/entities/chat-settings.entity.d.ts +5 -1
  170. package/dist/services/chats/entities/chat-settings.entity.js +10 -3
  171. package/dist/services/chats/entities/chat-settings.entity.mjs +10 -3
  172. package/dist/skills/skill.d.ts +2 -1
  173. package/dist/skills/skill.js +4 -3
  174. package/dist/skills/skill.mjs +4 -3
  175. package/docs/README.md +1 -1
  176. package/docs/agent.md +3 -2
  177. package/docs/authentication.md +18 -1
  178. package/docs/automations.md +341 -0
  179. package/docs/chats.md +1 -1
  180. package/docs/configuration.md +8 -7
  181. package/docs/harness.md +1 -1
  182. package/docs/integration-guide.md +22 -18
  183. package/docs/llms.txt +1 -1
  184. package/docs/mcp-servers.md +1 -1
  185. package/docs/skills.md +1 -1
  186. package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
  187. package/examples/automations/create-event-automation.ts +24 -0
  188. package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
  189. package/examples/automations/list-automations.ts +25 -0
  190. package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
  191. package/examples/automations/receive-automation-event.ts +26 -0
  192. package/examples/automations/revoke-automation-event-token.ts +25 -0
  193. package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
  194. package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
  195. package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
  196. package/package.json +14 -13
  197. package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
  198. package/dist/db/indexes/agentic-job-runs.mjs +0 -9
  199. package/dist/db/indexes/agentic-jobs.d.ts +0 -2
  200. package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
  201. package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
  202. package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
  203. package/dist/services/agentic-jobs/entities/index.mjs +0 -3
  204. package/dist/services/agentic-jobs/index.d.ts +0 -4
  205. package/dist/services/agentic-jobs/index.mjs +0 -4
  206. package/dist/services/agentic-jobs/module.d.ts +0 -31
  207. package/dist/services/agentic-jobs/module.js +0 -132
  208. package/dist/services/agentic-jobs/module.mjs +0 -95
  209. package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
  210. package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
  211. package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
  212. package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
  213. package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
  214. package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
  215. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
  216. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
  217. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
  218. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
  219. package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
  220. package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
  221. package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
  222. package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
  223. package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
  224. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
  225. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
  226. package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
  227. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
  228. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
  229. package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
  230. package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
  231. package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
  232. package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
  233. package/docs/agentic-jobs.md +0 -217
  234. package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
  235. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
  236. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
  237. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
  238. /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
  239. /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
  240. /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
@@ -13,16 +13,18 @@ var __copyProps = (to, from, except, desc) => {
13
13
  };
14
14
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var agentic_jobs_exports = {};
17
- module.exports = __toCommonJS(agentic_jobs_exports);
18
- __reExport(agentic_jobs_exports, require("./module"), module.exports);
19
- __reExport(agentic_jobs_exports, require("./entities"), module.exports);
20
- __reExport(agentic_jobs_exports, require("./repositories"), module.exports);
21
- __reExport(agentic_jobs_exports, require("./runner/agentic-job-runner"), module.exports);
16
+ var automations_exports = {};
17
+ module.exports = __toCommonJS(automations_exports);
18
+ __reExport(automations_exports, require("./module"), module.exports);
19
+ __reExport(automations_exports, require("./entities"), module.exports);
20
+ __reExport(automations_exports, require("./repositories"), module.exports);
21
+ __reExport(automations_exports, require("./runner/automation-runner"), module.exports);
22
+ __reExport(automations_exports, require("./utils/automation-event-error"), module.exports);
22
23
  // Annotate the CommonJS export names for ESM import in node:
23
24
  0 && (module.exports = {
24
25
  ...require("./module"),
25
26
  ...require("./entities"),
26
27
  ...require("./repositories"),
27
- ...require("./runner/agentic-job-runner")
28
+ ...require("./runner/automation-runner"),
29
+ ...require("./utils/automation-event-error")
28
30
  });
@@ -0,0 +1,5 @@
1
+ export * from "./module";
2
+ export * from "./entities";
3
+ export * from "./repositories";
4
+ export * from "./runner/automation-runner";
5
+ export * from "./utils/automation-event-error";
@@ -0,0 +1,41 @@
1
+ import 'reflect-metadata';
2
+ import { Params as CParams, Output as COutput } from './use-cases/create-automation.use-case';
3
+ import { Params as UParams, Output as UOutput } from './use-cases/update-automation.use-case';
4
+ import { Params as GParams, Output as GOutput } from './use-cases/get-automation-by-id.use-case';
5
+ import { Params as LParams, Output as LOutput } from './use-cases/list-automations-by-user.use-case';
6
+ import { Params as DParams, Output as DOutput } from './use-cases/delete-automation.use-case';
7
+ import { Params as PParams, Output as POutput } from './use-cases/preview-automation-runs.use-case';
8
+ import { Params as RJParams, Output as RJOutput } from './use-cases/list-automation-runs-by-automation.use-case';
9
+ import { Params as RUParams, Output as RUOutput } from './use-cases/list-automation-runs-by-user.use-case';
10
+ import { Params as CDParams, Output as CDOutput } from './use-cases/claim-due-automations.use-case';
11
+ import { Params as SRParams, Output as SROutput } from './use-cases/start-automation-run.use-case';
12
+ import { Params as FRParams, Output as FROutput } from './use-cases/finish-automation-run.use-case';
13
+ import { Params as SYParams, Output as SYOutput } from './use-cases/sync-automation-run.use-case';
14
+ import { Params as SYSParams, Output as SYSOutput } from './use-cases/sync-automation-runs.use-case';
15
+ import { Params as ACParams, Output as ACOutput } from './use-cases/attach-automation-run-chat.use-case';
16
+ import { Params as RLParams, Output as RLOutput } from './use-cases/renew-automation-lease.use-case';
17
+ import { Params as ITParams, Output as ITOutput } from './use-cases/issue-automation-event-token.use-case';
18
+ import { Params as RTParams, Output as RTOutput } from './use-cases/revoke-automation-event-token.use-case';
19
+ import { Params as ROParams, Output as ROOutput } from './use-cases/rotate-automation-event-tokens.use-case';
20
+ import { Params as REParams, Output as REOutput } from './use-cases/receive-automation-event.use-case';
21
+ import { Params as CQParams, Output as CQOutput } from './use-cases/claim-queued-automation-runs.use-case';
22
+ export declare function createAutomation(props: CParams): Promise<COutput>;
23
+ export declare function updateAutomation(props: UParams): Promise<UOutput>;
24
+ export declare function getAutomationById(props: GParams): Promise<GOutput>;
25
+ export declare function listAutomationsByUser(props: LParams): Promise<LOutput>;
26
+ export declare function deleteAutomation(props: DParams): Promise<DOutput>;
27
+ export declare function previewAutomationRuns(props: PParams): Promise<POutput>;
28
+ export declare function listAutomationRunsByAutomation(props: RJParams): Promise<RJOutput>;
29
+ export declare function listAutomationRunsByUser(props: RUParams): Promise<RUOutput>;
30
+ export declare function claimDueAutomations(props: CDParams): Promise<CDOutput>;
31
+ export declare function startAutomationRun(props: SRParams): Promise<SROutput>;
32
+ export declare function finishAutomationRun(props: FRParams): Promise<FROutput>;
33
+ export declare function syncAutomationRun(props: SYParams): Promise<SYOutput>;
34
+ export declare function syncAutomationRuns(props?: SYSParams): Promise<SYSOutput>;
35
+ export declare function attachAutomationRunChat(props: ACParams): Promise<ACOutput>;
36
+ export declare function renewAutomationLease(props: RLParams): Promise<RLOutput>;
37
+ export declare function issueAutomationEventToken(props: ITParams): Promise<ITOutput>;
38
+ export declare function revokeAutomationEventToken(props: RTParams): Promise<RTOutput>;
39
+ export declare function rotateAutomationEventTokens(props: ROParams): Promise<ROOutput>;
40
+ export declare function receiveAutomationEvent(props: REParams): Promise<REOutput>;
41
+ export declare function claimQueuedAutomationRuns(props: CQParams): Promise<CQOutput>;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var module_exports = {};
20
+ __export(module_exports, {
21
+ attachAutomationRunChat: () => attachAutomationRunChat,
22
+ claimDueAutomations: () => claimDueAutomations,
23
+ claimQueuedAutomationRuns: () => claimQueuedAutomationRuns,
24
+ createAutomation: () => createAutomation,
25
+ deleteAutomation: () => deleteAutomation,
26
+ finishAutomationRun: () => finishAutomationRun,
27
+ getAutomationById: () => getAutomationById,
28
+ issueAutomationEventToken: () => issueAutomationEventToken,
29
+ listAutomationRunsByAutomation: () => listAutomationRunsByAutomation,
30
+ listAutomationRunsByUser: () => listAutomationRunsByUser,
31
+ listAutomationsByUser: () => listAutomationsByUser,
32
+ previewAutomationRuns: () => previewAutomationRuns,
33
+ receiveAutomationEvent: () => receiveAutomationEvent,
34
+ renewAutomationLease: () => renewAutomationLease,
35
+ revokeAutomationEventToken: () => revokeAutomationEventToken,
36
+ rotateAutomationEventTokens: () => rotateAutomationEventTokens,
37
+ startAutomationRun: () => startAutomationRun,
38
+ syncAutomationRun: () => syncAutomationRun,
39
+ syncAutomationRuns: () => syncAutomationRuns,
40
+ updateAutomation: () => updateAutomation
41
+ });
42
+ module.exports = __toCommonJS(module_exports);
43
+ var import_reflect_metadata = require("reflect-metadata");
44
+ var import_tsyringe = require("tsyringe");
45
+ var import_create_automation = require("./use-cases/create-automation.use-case");
46
+ var import_update_automation = require("./use-cases/update-automation.use-case");
47
+ var import_get_automation_by_id = require("./use-cases/get-automation-by-id.use-case");
48
+ var import_list_automations_by_user = require("./use-cases/list-automations-by-user.use-case");
49
+ var import_delete_automation = require("./use-cases/delete-automation.use-case");
50
+ var import_preview_automation_runs = require("./use-cases/preview-automation-runs.use-case");
51
+ var import_list_automation_runs_by_automation = require("./use-cases/list-automation-runs-by-automation.use-case");
52
+ var import_list_automation_runs_by_user = require("./use-cases/list-automation-runs-by-user.use-case");
53
+ var import_claim_due_automations = require("./use-cases/claim-due-automations.use-case");
54
+ var import_start_automation_run = require("./use-cases/start-automation-run.use-case");
55
+ var import_finish_automation_run = require("./use-cases/finish-automation-run.use-case");
56
+ var import_sync_automation_run = require("./use-cases/sync-automation-run.use-case");
57
+ var import_sync_automation_runs = require("./use-cases/sync-automation-runs.use-case");
58
+ var import_attach_automation_run_chat = require("./use-cases/attach-automation-run-chat.use-case");
59
+ var import_renew_automation_lease = require("./use-cases/renew-automation-lease.use-case");
60
+ var import_issue_automation_event_token = require("./use-cases/issue-automation-event-token.use-case");
61
+ var import_revoke_automation_event_token = require("./use-cases/revoke-automation-event-token.use-case");
62
+ var import_rotate_automation_event_tokens = require("./use-cases/rotate-automation-event-tokens.use-case");
63
+ var import_receive_automation_event = require("./use-cases/receive-automation-event.use-case");
64
+ var import_claim_queued_automation_runs = require("./use-cases/claim-queued-automation-runs.use-case");
65
+ async function createAutomation(props) {
66
+ const createAutomationUseCase = import_tsyringe.container.resolve(import_create_automation.CreateAutomationUseCase);
67
+ return createAutomationUseCase.execute(props);
68
+ }
69
+ async function updateAutomation(props) {
70
+ const updateAutomationUseCase = import_tsyringe.container.resolve(import_update_automation.UpdateAutomationUseCase);
71
+ return updateAutomationUseCase.execute(props);
72
+ }
73
+ async function getAutomationById(props) {
74
+ const getAutomationByIdUseCase = import_tsyringe.container.resolve(import_get_automation_by_id.GetAutomationByIdUseCase);
75
+ return getAutomationByIdUseCase.execute(props);
76
+ }
77
+ async function listAutomationsByUser(props) {
78
+ const listAutomationsByUserUseCase = import_tsyringe.container.resolve(import_list_automations_by_user.ListAutomationsByUserUseCase);
79
+ return listAutomationsByUserUseCase.execute(props);
80
+ }
81
+ async function deleteAutomation(props) {
82
+ const deleteAutomationUseCase = import_tsyringe.container.resolve(import_delete_automation.DeleteAutomationUseCase);
83
+ return deleteAutomationUseCase.execute(props);
84
+ }
85
+ async function previewAutomationRuns(props) {
86
+ const previewAutomationRunsUseCase = import_tsyringe.container.resolve(import_preview_automation_runs.PreviewAutomationRunsUseCase);
87
+ return previewAutomationRunsUseCase.execute(props);
88
+ }
89
+ async function listAutomationRunsByAutomation(props) {
90
+ const listAutomationRunsByAutomationUseCase = import_tsyringe.container.resolve(import_list_automation_runs_by_automation.ListAutomationRunsByAutomationUseCase);
91
+ return listAutomationRunsByAutomationUseCase.execute(props);
92
+ }
93
+ async function listAutomationRunsByUser(props) {
94
+ const listAutomationRunsByUserUseCase = import_tsyringe.container.resolve(import_list_automation_runs_by_user.ListAutomationRunsByUserUseCase);
95
+ return listAutomationRunsByUserUseCase.execute(props);
96
+ }
97
+ async function claimDueAutomations(props) {
98
+ const claimDueAutomationsUseCase = import_tsyringe.container.resolve(import_claim_due_automations.ClaimDueAutomationsUseCase);
99
+ return claimDueAutomationsUseCase.execute(props);
100
+ }
101
+ async function startAutomationRun(props) {
102
+ const startAutomationRunUseCase = import_tsyringe.container.resolve(import_start_automation_run.StartAutomationRunUseCase);
103
+ return startAutomationRunUseCase.execute(props);
104
+ }
105
+ async function finishAutomationRun(props) {
106
+ const finishAutomationRunUseCase = import_tsyringe.container.resolve(import_finish_automation_run.FinishAutomationRunUseCase);
107
+ return finishAutomationRunUseCase.execute(props);
108
+ }
109
+ async function syncAutomationRun(props) {
110
+ const syncAutomationRunUseCase = import_tsyringe.container.resolve(import_sync_automation_run.SyncAutomationRunUseCase);
111
+ return syncAutomationRunUseCase.execute(props);
112
+ }
113
+ async function syncAutomationRuns(props = {}) {
114
+ const syncAutomationRunsUseCase = import_tsyringe.container.resolve(import_sync_automation_runs.SyncAutomationRunsUseCase);
115
+ return syncAutomationRunsUseCase.execute(props);
116
+ }
117
+ async function attachAutomationRunChat(props) {
118
+ const attachAutomationRunChatUseCase = import_tsyringe.container.resolve(import_attach_automation_run_chat.AttachAutomationRunChatUseCase);
119
+ return attachAutomationRunChatUseCase.execute(props);
120
+ }
121
+ async function renewAutomationLease(props) {
122
+ const renewAutomationLeaseUseCase = import_tsyringe.container.resolve(import_renew_automation_lease.RenewAutomationLeaseUseCase);
123
+ return renewAutomationLeaseUseCase.execute(props);
124
+ }
125
+ async function issueAutomationEventToken(props) {
126
+ const issueAutomationEventTokenUseCase = import_tsyringe.container.resolve(import_issue_automation_event_token.IssueAutomationEventTokenUseCase);
127
+ return issueAutomationEventTokenUseCase.execute(props);
128
+ }
129
+ async function revokeAutomationEventToken(props) {
130
+ const revokeAutomationEventTokenUseCase = import_tsyringe.container.resolve(import_revoke_automation_event_token.RevokeAutomationEventTokenUseCase);
131
+ return revokeAutomationEventTokenUseCase.execute(props);
132
+ }
133
+ async function rotateAutomationEventTokens(props) {
134
+ const rotateAutomationEventTokensUseCase = import_tsyringe.container.resolve(import_rotate_automation_event_tokens.RotateAutomationEventTokensUseCase);
135
+ return rotateAutomationEventTokensUseCase.execute(props);
136
+ }
137
+ async function receiveAutomationEvent(props) {
138
+ const receiveAutomationEventUseCase = import_tsyringe.container.resolve(import_receive_automation_event.ReceiveAutomationEventUseCase);
139
+ return receiveAutomationEventUseCase.execute(props);
140
+ }
141
+ async function claimQueuedAutomationRuns(props) {
142
+ const claimQueuedAutomationRunsUseCase = import_tsyringe.container.resolve(import_claim_queued_automation_runs.ClaimQueuedAutomationRunsUseCase);
143
+ return claimQueuedAutomationRunsUseCase.execute(props);
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ attachAutomationRunChat,
148
+ claimDueAutomations,
149
+ claimQueuedAutomationRuns,
150
+ createAutomation,
151
+ deleteAutomation,
152
+ finishAutomationRun,
153
+ getAutomationById,
154
+ issueAutomationEventToken,
155
+ listAutomationRunsByAutomation,
156
+ listAutomationRunsByUser,
157
+ listAutomationsByUser,
158
+ previewAutomationRuns,
159
+ receiveAutomationEvent,
160
+ renewAutomationLease,
161
+ revokeAutomationEventToken,
162
+ rotateAutomationEventTokens,
163
+ startAutomationRun,
164
+ syncAutomationRun,
165
+ syncAutomationRuns,
166
+ updateAutomation
167
+ });
@@ -0,0 +1,125 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ import "reflect-metadata";
3
+ import { container } from "tsyringe";
4
+ import { CreateAutomationUseCase } from "./use-cases/create-automation.use-case";
5
+ import { UpdateAutomationUseCase } from "./use-cases/update-automation.use-case";
6
+ import { GetAutomationByIdUseCase } from "./use-cases/get-automation-by-id.use-case";
7
+ import { ListAutomationsByUserUseCase } from "./use-cases/list-automations-by-user.use-case";
8
+ import { DeleteAutomationUseCase } from "./use-cases/delete-automation.use-case";
9
+ import { PreviewAutomationRunsUseCase } from "./use-cases/preview-automation-runs.use-case";
10
+ import { ListAutomationRunsByAutomationUseCase } from "./use-cases/list-automation-runs-by-automation.use-case";
11
+ import { ListAutomationRunsByUserUseCase } from "./use-cases/list-automation-runs-by-user.use-case";
12
+ import { ClaimDueAutomationsUseCase } from "./use-cases/claim-due-automations.use-case";
13
+ import { StartAutomationRunUseCase } from "./use-cases/start-automation-run.use-case";
14
+ import { FinishAutomationRunUseCase } from "./use-cases/finish-automation-run.use-case";
15
+ import { SyncAutomationRunUseCase } from "./use-cases/sync-automation-run.use-case";
16
+ import { SyncAutomationRunsUseCase } from "./use-cases/sync-automation-runs.use-case";
17
+ import { AttachAutomationRunChatUseCase } from "./use-cases/attach-automation-run-chat.use-case";
18
+ import { RenewAutomationLeaseUseCase } from "./use-cases/renew-automation-lease.use-case";
19
+ import { IssueAutomationEventTokenUseCase } from "./use-cases/issue-automation-event-token.use-case";
20
+ import { RevokeAutomationEventTokenUseCase } from "./use-cases/revoke-automation-event-token.use-case";
21
+ import { RotateAutomationEventTokensUseCase } from "./use-cases/rotate-automation-event-tokens.use-case";
22
+ import { ReceiveAutomationEventUseCase } from "./use-cases/receive-automation-event.use-case";
23
+ import { ClaimQueuedAutomationRunsUseCase } from "./use-cases/claim-queued-automation-runs.use-case";
24
+ async function createAutomation(props) {
25
+ const createAutomationUseCase = container.resolve(CreateAutomationUseCase);
26
+ return createAutomationUseCase.execute(props);
27
+ }
28
+ async function updateAutomation(props) {
29
+ const updateAutomationUseCase = container.resolve(UpdateAutomationUseCase);
30
+ return updateAutomationUseCase.execute(props);
31
+ }
32
+ async function getAutomationById(props) {
33
+ const getAutomationByIdUseCase = container.resolve(GetAutomationByIdUseCase);
34
+ return getAutomationByIdUseCase.execute(props);
35
+ }
36
+ async function listAutomationsByUser(props) {
37
+ const listAutomationsByUserUseCase = container.resolve(ListAutomationsByUserUseCase);
38
+ return listAutomationsByUserUseCase.execute(props);
39
+ }
40
+ async function deleteAutomation(props) {
41
+ const deleteAutomationUseCase = container.resolve(DeleteAutomationUseCase);
42
+ return deleteAutomationUseCase.execute(props);
43
+ }
44
+ async function previewAutomationRuns(props) {
45
+ const previewAutomationRunsUseCase = container.resolve(PreviewAutomationRunsUseCase);
46
+ return previewAutomationRunsUseCase.execute(props);
47
+ }
48
+ async function listAutomationRunsByAutomation(props) {
49
+ const listAutomationRunsByAutomationUseCase = container.resolve(ListAutomationRunsByAutomationUseCase);
50
+ return listAutomationRunsByAutomationUseCase.execute(props);
51
+ }
52
+ async function listAutomationRunsByUser(props) {
53
+ const listAutomationRunsByUserUseCase = container.resolve(ListAutomationRunsByUserUseCase);
54
+ return listAutomationRunsByUserUseCase.execute(props);
55
+ }
56
+ async function claimDueAutomations(props) {
57
+ const claimDueAutomationsUseCase = container.resolve(ClaimDueAutomationsUseCase);
58
+ return claimDueAutomationsUseCase.execute(props);
59
+ }
60
+ async function startAutomationRun(props) {
61
+ const startAutomationRunUseCase = container.resolve(StartAutomationRunUseCase);
62
+ return startAutomationRunUseCase.execute(props);
63
+ }
64
+ async function finishAutomationRun(props) {
65
+ const finishAutomationRunUseCase = container.resolve(FinishAutomationRunUseCase);
66
+ return finishAutomationRunUseCase.execute(props);
67
+ }
68
+ async function syncAutomationRun(props) {
69
+ const syncAutomationRunUseCase = container.resolve(SyncAutomationRunUseCase);
70
+ return syncAutomationRunUseCase.execute(props);
71
+ }
72
+ async function syncAutomationRuns(props = {}) {
73
+ const syncAutomationRunsUseCase = container.resolve(SyncAutomationRunsUseCase);
74
+ return syncAutomationRunsUseCase.execute(props);
75
+ }
76
+ async function attachAutomationRunChat(props) {
77
+ const attachAutomationRunChatUseCase = container.resolve(AttachAutomationRunChatUseCase);
78
+ return attachAutomationRunChatUseCase.execute(props);
79
+ }
80
+ async function renewAutomationLease(props) {
81
+ const renewAutomationLeaseUseCase = container.resolve(RenewAutomationLeaseUseCase);
82
+ return renewAutomationLeaseUseCase.execute(props);
83
+ }
84
+ async function issueAutomationEventToken(props) {
85
+ const issueAutomationEventTokenUseCase = container.resolve(IssueAutomationEventTokenUseCase);
86
+ return issueAutomationEventTokenUseCase.execute(props);
87
+ }
88
+ async function revokeAutomationEventToken(props) {
89
+ const revokeAutomationEventTokenUseCase = container.resolve(RevokeAutomationEventTokenUseCase);
90
+ return revokeAutomationEventTokenUseCase.execute(props);
91
+ }
92
+ async function rotateAutomationEventTokens(props) {
93
+ const rotateAutomationEventTokensUseCase = container.resolve(RotateAutomationEventTokensUseCase);
94
+ return rotateAutomationEventTokensUseCase.execute(props);
95
+ }
96
+ async function receiveAutomationEvent(props) {
97
+ const receiveAutomationEventUseCase = container.resolve(ReceiveAutomationEventUseCase);
98
+ return receiveAutomationEventUseCase.execute(props);
99
+ }
100
+ async function claimQueuedAutomationRuns(props) {
101
+ const claimQueuedAutomationRunsUseCase = container.resolve(ClaimQueuedAutomationRunsUseCase);
102
+ return claimQueuedAutomationRunsUseCase.execute(props);
103
+ }
104
+ export {
105
+ attachAutomationRunChat,
106
+ claimDueAutomations,
107
+ claimQueuedAutomationRuns,
108
+ createAutomation,
109
+ deleteAutomation,
110
+ finishAutomationRun,
111
+ getAutomationById,
112
+ issueAutomationEventToken,
113
+ listAutomationRunsByAutomation,
114
+ listAutomationRunsByUser,
115
+ listAutomationsByUser,
116
+ previewAutomationRuns,
117
+ receiveAutomationEvent,
118
+ renewAutomationLease,
119
+ revokeAutomationEventToken,
120
+ rotateAutomationEventTokens,
121
+ startAutomationRun,
122
+ syncAutomationRun,
123
+ syncAutomationRuns,
124
+ updateAutomation
125
+ };
@@ -0,0 +1,14 @@
1
+ import { MongoRepository, QueryOptions } from '../../../common/repositories/index.js';
2
+ import { AutomationRun, AutomationRunProps, AutomationRunStatus } from '../entities';
3
+ export declare class AutomationRunRepository {
4
+ readonly _: MongoRepository<AutomationRunProps>;
5
+ create(run: AutomationRun): Promise<AutomationRun>;
6
+ update(run: AutomationRun): Promise<AutomationRunProps | null>;
7
+ findById(id: string): Promise<AutomationRunProps | null>;
8
+ findByAutomation(automationId: string, options?: QueryOptions): Promise<AutomationRunProps[]>;
9
+ findByOwner(ownerId: string, options?: QueryOptions, status?: AutomationRunStatus): Promise<AutomationRunProps[]>;
10
+ findByStatus(status: AutomationRunStatus, limit: number): Promise<AutomationRunProps[]>;
11
+ findByIdempotencyKey(automationId: string, idempotencyKey: string): Promise<AutomationRunProps | null>;
12
+ countQueued(automationId: string): Promise<number>;
13
+ claimQueued(id: string, fields: Pick<AutomationRunProps, 'workerId' | 'startedAt' | 'instructions' | 'modelProvider' | 'modelName'>): Promise<AutomationRunProps | null>;
14
+ }
@@ -24,19 +24,19 @@ var __decorateClass = (decorators, target, key, kind) => {
24
24
  if (kind && result) __defProp(target, key, result);
25
25
  return result;
26
26
  };
27
- var agentic_job_run_repository_exports = {};
28
- __export(agentic_job_run_repository_exports, {
29
- AgenticJobRunRepository: () => AgenticJobRunRepository
27
+ var automation_run_repository_exports = {};
28
+ __export(automation_run_repository_exports, {
29
+ AutomationRunRepository: () => AutomationRunRepository
30
30
  });
31
- module.exports = __toCommonJS(agentic_job_run_repository_exports);
31
+ module.exports = __toCommonJS(automation_run_repository_exports);
32
32
  var import_tsyringe = require("tsyringe");
33
33
  var import_mongodb = require("mongodb");
34
34
  var import_repositories = require("../../../common/repositories/index.js");
35
35
  var import_database_name = require("../../../common/utils/database-name.js");
36
- let AgenticJobRunRepository = class {
36
+ let AutomationRunRepository = class {
37
37
  _ = new import_repositories.MongoRepository({
38
38
  database: (0, import_database_name.getDatabaseName)(),
39
- collection: "agentic_job_runs"
39
+ collection: "automation_runs"
40
40
  });
41
41
  async create(run) {
42
42
  const id = await this._.createOne({ payload: run.toDocument() });
@@ -52,8 +52,8 @@ let AgenticJobRunRepository = class {
52
52
  async findById(id) {
53
53
  return await this._.findOne({ where: { _id: this._.parseId(id) } });
54
54
  }
55
- async findByJob(jobId, options) {
56
- return await this._.findMany({ where: { jobId: new import_mongodb.ObjectId(jobId) }, options });
55
+ async findByAutomation(automationId, options) {
56
+ return await this._.findMany({ where: { automationId: new import_mongodb.ObjectId(automationId) }, options });
57
57
  }
58
58
  async findByOwner(ownerId, options, status) {
59
59
  return await this._.findMany({ where: { ownerId: new import_mongodb.ObjectId(ownerId), ...status ? { status } : {} }, options });
@@ -61,11 +61,23 @@ let AgenticJobRunRepository = class {
61
61
  async findByStatus(status, limit) {
62
62
  return await this._.findMany({ where: { status }, options: { page: 1, limit, sortBy: { createdAt: 1 } } });
63
63
  }
64
+ async findByIdempotencyKey(automationId, idempotencyKey) {
65
+ return await this._.findOne({ where: { automationId: new import_mongodb.ObjectId(automationId), idempotencyKey } });
66
+ }
67
+ async countQueued(automationId) {
68
+ return await this._.count({ where: { automationId: new import_mongodb.ObjectId(automationId), status: "queued" } });
69
+ }
70
+ async claimQueued(id, fields) {
71
+ return await this._.updateOne({
72
+ where: { _id: this._.parseId(id), status: "queued" },
73
+ payload: { ...fields, status: "running" }
74
+ });
75
+ }
64
76
  };
65
- AgenticJobRunRepository = __decorateClass([
77
+ AutomationRunRepository = __decorateClass([
66
78
  (0, import_tsyringe.autoInjectable)()
67
- ], AgenticJobRunRepository);
79
+ ], AutomationRunRepository);
68
80
  // Annotate the CommonJS export names for ESM import in node:
69
81
  0 && (module.exports = {
70
- AgenticJobRunRepository
82
+ AutomationRunRepository
71
83
  });
@@ -5,10 +5,10 @@ import { autoInjectable } from "tsyringe";
5
5
  import { ObjectId } from "mongodb";
6
6
  import { MongoRepository } from "../../../common/repositories/index.js";
7
7
  import { getDatabaseName } from "../../../common/utils/database-name.js";
8
- let AgenticJobRunRepository = class {
8
+ let AutomationRunRepository = class {
9
9
  _ = new MongoRepository({
10
10
  database: getDatabaseName(),
11
- collection: "agentic_job_runs"
11
+ collection: "automation_runs"
12
12
  });
13
13
  async create(run) {
14
14
  const id = await this._.createOne({ payload: run.toDocument() });
@@ -24,8 +24,8 @@ let AgenticJobRunRepository = class {
24
24
  async findById(id) {
25
25
  return await this._.findOne({ where: { _id: this._.parseId(id) } });
26
26
  }
27
- async findByJob(jobId, options) {
28
- return await this._.findMany({ where: { jobId: new ObjectId(jobId) }, options });
27
+ async findByAutomation(automationId, options) {
28
+ return await this._.findMany({ where: { automationId: new ObjectId(automationId) }, options });
29
29
  }
30
30
  async findByOwner(ownerId, options, status) {
31
31
  return await this._.findMany({ where: { ownerId: new ObjectId(ownerId), ...status ? { status } : {} }, options });
@@ -33,10 +33,22 @@ let AgenticJobRunRepository = class {
33
33
  async findByStatus(status, limit) {
34
34
  return await this._.findMany({ where: { status }, options: { page: 1, limit, sortBy: { createdAt: 1 } } });
35
35
  }
36
+ async findByIdempotencyKey(automationId, idempotencyKey) {
37
+ return await this._.findOne({ where: { automationId: new ObjectId(automationId), idempotencyKey } });
38
+ }
39
+ async countQueued(automationId) {
40
+ return await this._.count({ where: { automationId: new ObjectId(automationId), status: "queued" } });
41
+ }
42
+ async claimQueued(id, fields) {
43
+ return await this._.updateOne({
44
+ where: { _id: this._.parseId(id), status: "queued" },
45
+ payload: { ...fields, status: "running" }
46
+ });
47
+ }
36
48
  };
37
- AgenticJobRunRepository = __decorateClass([
49
+ AutomationRunRepository = __decorateClass([
38
50
  autoInjectable()
39
- ], AgenticJobRunRepository);
51
+ ], AutomationRunRepository);
40
52
  export {
41
- AgenticJobRunRepository
53
+ AutomationRunRepository
42
54
  };
@@ -0,0 +1,27 @@
1
+ import { MongoRepository, QueryOptions } from '../../../common/repositories/index.js';
2
+ import { Automation, AutomationProps, AutomationRunStatus } from '../entities';
3
+ export interface ClaimParams {
4
+ id: string;
5
+ workerId: string;
6
+ now: Date;
7
+ leaseMs: number;
8
+ nextRunAt?: Date;
9
+ }
10
+ export declare class AutomationRepository {
11
+ readonly _: MongoRepository<AutomationProps>;
12
+ create(automation: Automation): Promise<Automation>;
13
+ update(automation: Automation, options?: {
14
+ expectedVersion?: number;
15
+ }): Promise<AutomationProps | null>;
16
+ findById(id: string): Promise<AutomationProps | null>;
17
+ findByOwner(ownerId: string, options?: QueryOptions): Promise<AutomationProps[]>;
18
+ deleteById(id: string): Promise<number>;
19
+ findDue(now: Date, limit: number): Promise<AutomationProps[]>;
20
+ claim(params: ClaimParams): Promise<AutomationProps | null>;
21
+ claimManual(params: Omit<ClaimParams, 'nextRunAt'>): Promise<AutomationProps | null>;
22
+ setActiveRun(id: string, workerId: string, runId: string): Promise<AutomationProps | null>;
23
+ settleRun(id: string, runId: string, status: AutomationRunStatus, at: Date): Promise<AutomationProps | null>;
24
+ renewLease(id: string, workerId: string, until: Date): Promise<AutomationProps | null>;
25
+ release(id: string, workerId: string, result: Pick<AutomationProps, 'lastRunAt' | 'lastRunStatus' | 'activeRunId'>): Promise<AutomationProps | null>;
26
+ private unlocked;
27
+ }
@@ -24,30 +24,30 @@ var __decorateClass = (decorators, target, key, kind) => {
24
24
  if (kind && result) __defProp(target, key, result);
25
25
  return result;
26
26
  };
27
- var agentic_job_repository_exports = {};
28
- __export(agentic_job_repository_exports, {
29
- AgenticJobRepository: () => AgenticJobRepository
27
+ var automation_repository_exports = {};
28
+ __export(automation_repository_exports, {
29
+ AutomationRepository: () => AutomationRepository
30
30
  });
31
- module.exports = __toCommonJS(agentic_job_repository_exports);
31
+ module.exports = __toCommonJS(automation_repository_exports);
32
32
  var import_tsyringe = require("tsyringe");
33
33
  var import_mongodb = require("mongodb");
34
34
  var import_repositories = require("../../../common/repositories/index.js");
35
35
  var import_database_name = require("../../../common/utils/database-name.js");
36
- let AgenticJobRepository = class {
36
+ let AutomationRepository = class {
37
37
  _ = new import_repositories.MongoRepository({
38
38
  database: (0, import_database_name.getDatabaseName)(),
39
- collection: "agentic_jobs"
39
+ collection: "automations"
40
40
  });
41
- async create(job) {
42
- const id = await this._.createOne({ payload: job.toDocument() });
43
- id && job.setId(id);
44
- return job;
41
+ async create(automation) {
42
+ const id = await this._.createOne({ payload: automation.toDocument() });
43
+ id && automation.setId(id);
44
+ return automation;
45
45
  }
46
- async update(job, options) {
47
- if (options && typeof options.expectedVersion !== "number") throw new Error("[AgenticJobRepository] The expected version is required to check for conflicts");
46
+ async update(automation, options) {
47
+ if (options && typeof options.expectedVersion !== "number") throw new Error("[AutomationRepository] The expected version is required to check for conflicts");
48
48
  return await this._.updateOne({
49
- where: { _id: job._id },
50
- payload: job.toFlatDocument(),
49
+ where: { _id: automation._id },
50
+ payload: automation.toFlatDocument(),
51
51
  expectedVersion: options?.expectedVersion
52
52
  });
53
53
  }
@@ -118,10 +118,10 @@ let AgenticJobRepository = class {
118
118
  return { $or: [{ lockedUntil: { $exists: false } }, { lockedUntil: null }, { lockedUntil: { $lte: now } }] };
119
119
  }
120
120
  };
121
- AgenticJobRepository = __decorateClass([
121
+ AutomationRepository = __decorateClass([
122
122
  (0, import_tsyringe.autoInjectable)()
123
- ], AgenticJobRepository);
123
+ ], AutomationRepository);
124
124
  // Annotate the CommonJS export names for ESM import in node:
125
125
  0 && (module.exports = {
126
- AgenticJobRepository
126
+ AutomationRepository
127
127
  });
@@ -5,21 +5,21 @@ import { autoInjectable } from "tsyringe";
5
5
  import { ObjectId } from "mongodb";
6
6
  import { MongoRepository } from "../../../common/repositories/index.js";
7
7
  import { getDatabaseName } from "../../../common/utils/database-name.js";
8
- let AgenticJobRepository = class {
8
+ let AutomationRepository = class {
9
9
  _ = new MongoRepository({
10
10
  database: getDatabaseName(),
11
- collection: "agentic_jobs"
11
+ collection: "automations"
12
12
  });
13
- async create(job) {
14
- const id = await this._.createOne({ payload: job.toDocument() });
15
- id && job.setId(id);
16
- return job;
13
+ async create(automation) {
14
+ const id = await this._.createOne({ payload: automation.toDocument() });
15
+ id && automation.setId(id);
16
+ return automation;
17
17
  }
18
- async update(job, options) {
19
- if (options && typeof options.expectedVersion !== "number") throw new Error("[AgenticJobRepository] The expected version is required to check for conflicts");
18
+ async update(automation, options) {
19
+ if (options && typeof options.expectedVersion !== "number") throw new Error("[AutomationRepository] The expected version is required to check for conflicts");
20
20
  return await this._.updateOne({
21
- where: { _id: job._id },
22
- payload: job.toFlatDocument(),
21
+ where: { _id: automation._id },
22
+ payload: automation.toFlatDocument(),
23
23
  expectedVersion: options?.expectedVersion
24
24
  });
25
25
  }
@@ -90,9 +90,9 @@ let AgenticJobRepository = class {
90
90
  return { $or: [{ lockedUntil: { $exists: false } }, { lockedUntil: null }, { lockedUntil: { $lte: now } }] };
91
91
  }
92
92
  };
93
- AgenticJobRepository = __decorateClass([
93
+ AutomationRepository = __decorateClass([
94
94
  autoInjectable()
95
- ], AgenticJobRepository);
95
+ ], AutomationRepository);
96
96
  export {
97
- AgenticJobRepository
97
+ AutomationRepository
98
98
  };
@@ -0,0 +1,2 @@
1
+ export * from './automation.repository';
2
+ export * from './automation-run.repository';