openloops 0.3.5 → 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 (217) hide show
  1. package/README.md +9 -8
  2. package/dist/db/index.d.ts +1 -0
  3. package/dist/db/index.js +3 -1
  4. package/dist/db/index.mjs +1 -0
  5. package/dist/db/indexes/automation-runs.d.ts +2 -0
  6. package/dist/db/indexes/automation-runs.js +33 -0
  7. package/dist/db/indexes/automation-runs.mjs +10 -0
  8. package/dist/db/indexes/automations.d.ts +2 -0
  9. package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
  10. package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
  11. package/dist/db/indexes/index.js +6 -4
  12. package/dist/db/indexes/index.mjs +6 -4
  13. package/dist/db/indexes/revoked-tokens.d.ts +2 -0
  14. package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
  15. package/dist/db/indexes/revoked-tokens.mjs +8 -0
  16. package/dist/db/migrations/automations.d.ts +12 -0
  17. package/dist/db/migrations/automations.js +70 -0
  18. package/dist/db/migrations/automations.mjs +47 -0
  19. package/dist/services/authentication/entities/index.d.ts +1 -0
  20. package/dist/services/authentication/entities/index.js +22 -0
  21. package/dist/services/authentication/entities/index.mjs +1 -0
  22. package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
  23. package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
  24. package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
  25. package/dist/services/authentication/index.d.ts +1 -0
  26. package/dist/services/authentication/index.js +3 -1
  27. package/dist/services/authentication/index.mjs +1 -0
  28. package/dist/services/authentication/module.d.ts +4 -0
  29. package/dist/services/authentication/module.js +16 -2
  30. package/dist/services/authentication/module.mjs +13 -1
  31. package/dist/services/authentication/repositories/index.d.ts +1 -0
  32. package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
  33. package/dist/services/authentication/repositories/index.mjs +1 -0
  34. package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
  35. package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
  36. package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
  37. package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
  38. package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
  39. package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
  40. package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
  41. package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
  42. package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
  43. package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
  44. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
  45. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
  46. package/dist/services/automations/entities/automation.entity.d.ts +38 -0
  47. package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
  48. package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
  49. package/dist/services/automations/entities/index.d.ts +4 -0
  50. package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
  51. package/dist/services/automations/entities/index.mjs +4 -0
  52. package/dist/services/automations/entities/trigger.d.ts +11 -0
  53. package/dist/services/automations/entities/trigger.js +49 -0
  54. package/dist/services/automations/entities/trigger.mjs +26 -0
  55. package/dist/services/automations/index.d.ts +5 -0
  56. package/dist/services/{agentic-jobs → automations}/index.js +9 -7
  57. package/dist/services/automations/index.mjs +5 -0
  58. package/dist/services/automations/module.d.ts +41 -0
  59. package/dist/services/automations/module.js +167 -0
  60. package/dist/services/automations/module.mjs +125 -0
  61. package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
  62. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
  63. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
  64. package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
  65. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
  66. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
  67. package/dist/services/automations/repositories/index.d.ts +2 -0
  68. package/dist/services/automations/repositories/index.js +24 -0
  69. package/dist/services/automations/repositories/index.mjs +2 -0
  70. package/dist/services/automations/runner/automation-runner.d.ts +49 -0
  71. package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
  72. package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
  73. 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
  74. 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
  75. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
  76. package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
  77. 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
  78. package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
  79. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
  80. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
  81. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
  82. package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
  83. package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
  84. package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
  85. 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
  86. package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
  87. package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
  88. 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
  89. 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
  90. package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
  91. 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
  92. 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
  93. package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
  94. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
  95. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
  96. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
  97. 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
  98. 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
  99. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. 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
  106. 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
  107. 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
  108. 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
  109. package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
  110. package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
  111. package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
  112. 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
  113. 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
  114. package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
  115. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
  116. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
  117. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
  118. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
  119. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
  120. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
  121. package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
  122. 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
  123. package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
  124. package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
  131. package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
  132. package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
  133. package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
  134. package/dist/services/automations/utils/automation-event-error.js +37 -0
  135. package/dist/services/automations/utils/automation-event-error.mjs +14 -0
  136. package/dist/services/automations/utils/automation-fields.d.ts +14 -0
  137. package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
  138. package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
  139. package/dist/services/automations/utils/event-message.d.ts +1 -0
  140. package/dist/services/automations/utils/event-message.js +37 -0
  141. package/dist/services/automations/utils/event-message.mjs +14 -0
  142. package/dist/services/automations/utils/event-token.d.ts +18 -0
  143. package/dist/services/automations/utils/event-token.js +78 -0
  144. package/dist/services/automations/utils/event-token.mjs +43 -0
  145. package/dist/services/automations/utils/open-run.d.ts +14 -0
  146. package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
  147. package/dist/services/automations/utils/open-run.mjs +26 -0
  148. package/dist/services/automations/utils/previous-run.d.ts +4 -0
  149. package/dist/services/automations/utils/previous-run.js +42 -0
  150. package/dist/services/automations/utils/previous-run.mjs +19 -0
  151. package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
  152. package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
  153. package/dist/services/automations/utils/settings.mjs +13 -0
  154. package/docs/README.md +1 -1
  155. package/docs/agent.md +2 -2
  156. package/docs/authentication.md +18 -1
  157. package/docs/automations.md +341 -0
  158. package/docs/configuration.md +6 -5
  159. package/docs/harness.md +1 -1
  160. package/docs/integration-guide.md +22 -18
  161. package/docs/llms.txt +1 -1
  162. package/docs/mcp-servers.md +1 -1
  163. package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
  164. package/examples/automations/create-event-automation.ts +24 -0
  165. package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
  166. package/examples/automations/list-automations.ts +25 -0
  167. package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
  168. package/examples/automations/receive-automation-event.ts +26 -0
  169. package/examples/automations/revoke-automation-event-token.ts +25 -0
  170. package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
  171. package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
  172. package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
  173. package/package.json +14 -13
  174. package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
  175. package/dist/db/indexes/agentic-job-runs.mjs +0 -9
  176. package/dist/db/indexes/agentic-jobs.d.ts +0 -2
  177. package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
  178. package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
  179. package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
  180. package/dist/services/agentic-jobs/entities/index.mjs +0 -3
  181. package/dist/services/agentic-jobs/index.d.ts +0 -4
  182. package/dist/services/agentic-jobs/index.mjs +0 -4
  183. package/dist/services/agentic-jobs/module.d.ts +0 -31
  184. package/dist/services/agentic-jobs/module.js +0 -132
  185. package/dist/services/agentic-jobs/module.mjs +0 -95
  186. package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
  187. package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
  188. package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
  189. package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
  190. package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
  191. package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
  192. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
  193. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
  194. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
  195. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
  196. package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
  197. package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
  198. package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
  199. package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
  200. package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
  201. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
  202. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
  203. package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
  204. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
  205. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
  206. package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
  207. package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
  208. package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
  209. package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
  210. package/docs/agentic-jobs.md +0 -217
  211. package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
  212. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
  213. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
  214. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
  215. /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
  216. /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
  217. /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
@@ -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';
@@ -0,0 +1,24 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var repositories_exports = {};
17
+ module.exports = __toCommonJS(repositories_exports);
18
+ __reExport(repositories_exports, require("./automation.repository"), module.exports);
19
+ __reExport(repositories_exports, require("./automation-run.repository"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./automation.repository"),
23
+ ...require("./automation-run.repository")
24
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./automation.repository";
2
+ export * from "./automation-run.repository";
@@ -0,0 +1,49 @@
1
+ import { CurrentUser } from '../../../common/base/index.js';
2
+ import { AgentOptions } from '../../../harness/agent.js';
3
+ import { Chat } from '../../chats/entities/chat.entity.js';
4
+ import { AutomationProps, AutomationRunProps } from '../entities';
5
+ export interface AutomationContext {
6
+ automation: AutomationProps;
7
+ currentUser: CurrentUser;
8
+ }
9
+ export type AutomationAgentConfig = Partial<AgentOptions> | ((context: AutomationContext) => Partial<AgentOptions> | Promise<Partial<AgentOptions>>);
10
+ export interface AutomationRunFinished {
11
+ automation: AutomationProps;
12
+ run: AutomationRunProps;
13
+ chat?: Chat;
14
+ }
15
+ export interface AutomationRunnerOptions {
16
+ agent?: AutomationAgentConfig;
17
+ intervalMs?: number;
18
+ leaseMs?: number;
19
+ maxConcurrentRuns?: number;
20
+ stopTimeoutMs?: number;
21
+ workerId?: string;
22
+ onRunFinished?: (event: AutomationRunFinished) => void | Promise<void>;
23
+ }
24
+ export declare class AutomationRunner {
25
+ private readonly options;
26
+ readonly workerId: string;
27
+ private readonly logger;
28
+ private readonly inFlight;
29
+ private running;
30
+ private timer?;
31
+ private ticking?;
32
+ private resolveSleep?;
33
+ constructor(options?: AutomationRunnerOptions);
34
+ start(): void;
35
+ wake(): void;
36
+ stop(): Promise<void>;
37
+ tick(): Promise<void>;
38
+ runNow(params: {
39
+ automationId: string;
40
+ }): Promise<{
41
+ run: AutomationRunProps;
42
+ }>;
43
+ private loop;
44
+ private track;
45
+ private execute;
46
+ private runAgent;
47
+ private notify;
48
+ }
49
+ export declare function createAutomationRunner(options?: AutomationRunnerOptions): AutomationRunner;