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
package/README.md CHANGED
@@ -40,7 +40,7 @@ A model alone only chats. The harness is what lets it act, safely, for many user
40
40
  | **Transmission** | Takes the model to the outside world | Your tools and MCP servers, found on demand and validated before they run. See [tools](docs/tools.md) and [MCP servers](docs/mcp-servers.md) |
41
41
  | **Brakes** | Stops the agent when it should stop | Confirmation of destructive tools, approval of MCP servers, input guardrails, timeouts and a budget per task. See [guardrails](docs/guardrails.md) and [the harness](docs/harness.md) |
42
42
  | **Logbook** | Remembers and records everything | Chats, tasks, every tool call, traces, and usage and cost per call. See [chats](docs/chats.md) and [usage](docs/usage.md) |
43
- | **Steering** | Decides how the agent is driven | Interactive and autonomous runs, scheduled jobs, stopping a run, and the model per chat and per user. See [the Agent](docs/agent.md), [agentic jobs](docs/agentic-jobs.md) and [configuration](docs/configuration.md) |
43
+ | **Steering** | Decides how the agent is driven | Interactive and autonomous runs, scheduled automations, stopping a run, and the model per chat and per user. See [the Agent](docs/agent.md), [automations](docs/automations.md) and [configuration](docs/configuration.md) |
44
44
 
45
45
  ## Why it is a good harness
46
46
 
@@ -56,7 +56,7 @@ Not adjectives, mechanisms that you can read in the code and in the tests:
56
56
 
57
57
  ## Building a backend with it
58
58
 
59
- If you or your coding agent are going to build the backend that uses `openloops`, start with the [integration guide](docs/integration-guide.md). It lists which endpoint calls which use case, what authorization is left to you (the package has no HTTP layer), how to run agents and scheduled jobs, and a security checklist. The whole documentation is also shipped inside the package, in `node_modules/openloops/docs`, with an index for tools in [`docs/llms.txt`](docs/llms.txt).
59
+ If you or your coding agent are going to build the backend that uses `openloops`, start with the [integration guide](docs/integration-guide.md). It lists which endpoint calls which use case, what authorization is left to you (the package has no HTTP layer), how to run agents and scheduled automations, and a security checklist. The whole documentation is also shipped inside the package, in `node_modules/openloops/docs`, with an index for tools in [`docs/llms.txt`](docs/llms.txt).
60
60
 
61
61
  To make sure that your coding agent reads it in every session, add this to the `CLAUDE.md` or `AGENTS.md` of your backend:
62
62
 
@@ -104,7 +104,7 @@ You know the pattern: before you write a single line of what your agent actually
104
104
  - **Safe tool execution.** Arguments are validated against the tool's schema, destructive tools wait for the user's confirmation, identical failing calls are blocked, identifiers the model invented are rejected before they reach a real system, and large outputs are kept out of the prompt. LLM calls retry with backoff and wait out rate limits.
105
105
  - **Native MCP support with a trust flow.** Connect any MCP server and its tools become regular tools. Each server must be approved by the user before its first tool runs, and a server that changes its tools is reviewed again, so a third party cannot quietly change what your agent does.
106
106
  - **Autonomous runs.** The same agent can work without a person in the chat, for scheduled tasks. Whatever needs the user pauses the run in the chat, and the user answers there to continue. See [autonomous mode](docs/agent.md#autonomous-mode).
107
- - **Agentic jobs.** Schedule tasks that the agent runs by itself, daily, weekly, monthly or once, in the timezone of the user. A worker runs what is due, safely across several instances, and keeps a history of every run with its chat. See [agentic jobs](docs/agentic-jobs.md).
107
+ - **Automations.** Tasks that the agent runs by itself, on a schedule (daily, weekly, monthly or once, in the timezone of the user) or when another system sends an event, with signed tokens that can be revoked and a queue per automation. A worker runs what is due, safely across several instances, and keeps a history of every run with its chat. See [automations](docs/automations.md).
108
108
  - **Guardrails.** Input guards block messages with card numbers, emails, code or anything you define, before the model sees them. See [guardrails](docs/guardrails.md).
109
109
  - **Usage and cost tracking.** Every LLM call is recorded. Get the tokens and cost of a chat or an answer, and per-user statistics by model and by period. See [usage](docs/usage.md).
110
110
  - **Users and authentication included.** User management and login with tokens, so you don't need a parallel system just to have an identity to hand the `Agent`.
@@ -219,8 +219,9 @@ LLM_FALLBACK_PROVIDER=
219
219
  LLM_FALLBACK_MODEL=
220
220
 
221
221
  # Optional, in milliseconds
222
- AGENTIC_JOBS_POLL_INTERVAL_MS=
223
- AGENTIC_JOBS_LEASE_MS=
222
+ AUTOMATIONS_POLL_INTERVAL_MS=
223
+ AUTOMATIONS_LEASE_MS=
224
+ AUTOMATIONS_MAX_QUEUED_RUNS=
224
225
  LLM_CALL_TIMEOUT_MS=
225
226
  MCP_TOOL_TIMEOUT_MS=
226
227
 
@@ -261,7 +262,7 @@ Neither requires any code changes. They're opt-in purely through environment var
261
262
 
262
263
  ## More examples
263
264
 
264
- Every pattern above, and a lot more, lives as a runnable example in [`examples/`](examples), organized by domain: `run-agent`, `loops`, `tools`, `guardrails`, `agentic-jobs`, `mcps`, `chats`, `usage`, `users`, and `authentication`.
265
+ Every pattern above, and a lot more, lives as a runnable example in [`examples/`](examples), organized by domain: `run-agent`, `loops`, `tools`, `guardrails`, `automations`, `mcps`, `chats`, `usage`, `users`, and `authentication`.
265
266
 
266
267
  ## Package structure
267
268
 
@@ -275,7 +276,7 @@ Every pattern above, and a lot more, lives as a runnable example in [`examples/`
275
276
  | `openloops/skills` | `Skill`, for writing LLM-backed reasoning steps inside a loop |
276
277
  | `openloops/guardrails` | `Guard` and the ready-made input guards |
277
278
  | `openloops/mcps` | MCP server management, connection check and trust decisions |
278
- | `openloops/agentic-jobs` | Scheduled tasks, their runs and the runner that executes them |
279
+ | `openloops/automations` | Scheduled and event tasks, their runs and the runner that executes them |
279
280
  | `openloops/chats` | Chats and their messages: list, read, update, delete |
280
281
  | `openloops/users` | User management |
281
282
  | `openloops/authentication` | Login and token issuing |
@@ -295,7 +296,7 @@ Every pattern above, and a lot more, lives as a runnable example in [`examples/`
295
296
  - [Skills](docs/skills.md)
296
297
  - [Guardrails](docs/guardrails.md)
297
298
  - [MCP servers](docs/mcp-servers.md)
298
- - [Agentic jobs](docs/agentic-jobs.md)
299
+ - [Automations](docs/automations.md)
299
300
  - [Chats](docs/chats.md)
300
301
  - [User management](docs/users.md)
301
302
  - [Authentication](docs/authentication.md)
@@ -45,6 +45,7 @@ const MAX_RETRIES = 4;
45
45
  const MAX_RATE_LIMIT_WAITS = 2;
46
46
  const DEFAULT_CALL_TIMEOUT_MS = 6e4;
47
47
  const MAX_TIMEOUT_RETRIES = 2;
48
+ const HIGH_THINKING_TIMEOUT_FACTOR = 2;
48
49
  const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
49
50
  const REQUIRED_TOOL_CHOICE = {
50
51
  "anthropic-messages": "any",
@@ -98,7 +99,7 @@ class LLMClient {
98
99
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
99
100
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
100
101
  const context = (0, import_pi_ai_adapter.toPiContext)({ messages, tools }, model);
101
- const send = (omitTemperature) => this.withDeadline((signal) => {
102
+ const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
102
103
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
103
104
  const reasoning = thinking && thinking !== "off" ? thinking : void 0;
104
105
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
@@ -121,7 +122,7 @@ class LLMClient {
121
122
  user: (0, import_model_resolution.toModelRef)(currentUser?.preferences?.defaultModel)
122
123
  });
123
124
  }
124
- async withDeadline(call) {
125
+ async withDeadline(timeoutMs, call) {
125
126
  for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
126
127
  const controller = new AbortController();
127
128
  let timer;
@@ -129,15 +130,15 @@ class LLMClient {
129
130
  timer = setTimeout(() => {
130
131
  controller.abort();
131
132
  resolve(void 0);
132
- }, this.callTimeoutMs);
133
+ }, timeoutMs);
133
134
  });
134
135
  const pending = call(controller.signal);
135
136
  pending.catch(() => void 0);
136
137
  const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
137
138
  if (response) return response;
138
- this.logger.warn({ attempt, timeoutMs: this.callTimeoutMs }, "[LLM Service] The model did not answer in time");
139
+ this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
139
140
  }
140
- throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${this.callTimeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
141
+ throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
141
142
  }
142
143
  async flushLangfuse() {
143
144
  if (!this.langfuseEnabled) return;
@@ -13,6 +13,7 @@ const MAX_RETRIES = 4;
13
13
  const MAX_RATE_LIMIT_WAITS = 2;
14
14
  const DEFAULT_CALL_TIMEOUT_MS = 6e4;
15
15
  const MAX_TIMEOUT_RETRIES = 2;
16
+ const HIGH_THINKING_TIMEOUT_FACTOR = 2;
16
17
  const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
17
18
  const REQUIRED_TOOL_CHOICE = {
18
19
  "anthropic-messages": "any",
@@ -66,7 +67,7 @@ class LLMClient {
66
67
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
67
68
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
68
69
  const context = toPiContext({ messages, tools }, model);
69
- const send = (omitTemperature) => this.withDeadline((signal) => {
70
+ const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
70
71
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
71
72
  const reasoning = thinking && thinking !== "off" ? thinking : void 0;
72
73
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
@@ -89,7 +90,7 @@ class LLMClient {
89
90
  user: toModelRef(currentUser?.preferences?.defaultModel)
90
91
  });
91
92
  }
92
- async withDeadline(call) {
93
+ async withDeadline(timeoutMs, call) {
93
94
  for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
94
95
  const controller = new AbortController();
95
96
  let timer;
@@ -97,15 +98,15 @@ class LLMClient {
97
98
  timer = setTimeout(() => {
98
99
  controller.abort();
99
100
  resolve(void 0);
100
- }, this.callTimeoutMs);
101
+ }, timeoutMs);
101
102
  });
102
103
  const pending = call(controller.signal);
103
104
  pending.catch(() => void 0);
104
105
  const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
105
106
  if (response) return response;
106
- this.logger.warn({ attempt, timeoutMs: this.callTimeoutMs }, "[LLM Service] The model did not answer in time");
107
+ this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
107
108
  }
108
- throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${this.callTimeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
109
+ throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
109
110
  }
110
111
  async flushLangfuse() {
111
112
  if (!this.langfuseEnabled) return;
@@ -51,6 +51,9 @@ export interface LLMResponse {
51
51
  }
52
52
  export type LLMToolChoice = 'auto' | 'none' | 'required';
53
53
  export type ThinkingEffort = 'off' | 'low' | 'medium' | 'high';
54
+ export declare const SELECTABLE_THINKING_EFFORTS: readonly ["low", "medium", "high"];
55
+ export type SelectableThinkingEffort = typeof SELECTABLE_THINKING_EFFORTS[number];
56
+ export declare const isSelectableThinkingEffort: (value: unknown) => value is SelectableThinkingEffort;
54
57
  export interface LLMChatParams {
55
58
  origin: string;
56
59
  sessionId: string;
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -13,4 +17,15 @@ var __copyProps = (to, from, except, desc) => {
13
17
  };
14
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
  var llm_types_exports = {};
20
+ __export(llm_types_exports, {
21
+ SELECTABLE_THINKING_EFFORTS: () => SELECTABLE_THINKING_EFFORTS,
22
+ isSelectableThinkingEffort: () => isSelectableThinkingEffort
23
+ });
16
24
  module.exports = __toCommonJS(llm_types_exports);
25
+ const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
26
+ const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ SELECTABLE_THINKING_EFFORTS,
30
+ isSelectableThinkingEffort
31
+ });
@@ -0,0 +1,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
3
+ const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
4
+ export {
5
+ SELECTABLE_THINKING_EFFORTS,
6
+ isSelectableThinkingEffort
7
+ };
@@ -1 +1,2 @@
1
1
  export * from './indexes';
2
+ export * from './migrations/automations';
package/dist/db/index.js CHANGED
@@ -16,7 +16,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var db_exports = {};
17
17
  module.exports = __toCommonJS(db_exports);
18
18
  __reExport(db_exports, require("./indexes"), module.exports);
19
+ __reExport(db_exports, require("./migrations/automations"), module.exports);
19
20
  // Annotate the CommonJS export names for ESM import in node:
20
21
  0 && (module.exports = {
21
- ...require("./indexes")
22
+ ...require("./indexes"),
23
+ ...require("./migrations/automations")
22
24
  });
package/dist/db/index.mjs CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./indexes";
2
+ export * from "./migrations/automations";
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const automationRuns: IndexDescription[];
@@ -0,0 +1,33 @@
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 automation_runs_exports = {};
20
+ __export(automation_runs_exports, {
21
+ automationRuns: () => automationRuns
22
+ });
23
+ module.exports = __toCommonJS(automation_runs_exports);
24
+ const automationRuns = [
25
+ { key: { automationId: 1, createdAt: -1 } },
26
+ { key: { ownerId: 1, createdAt: -1 } },
27
+ { key: { status: 1, createdAt: 1 } },
28
+ { key: { automationId: 1, idempotencyKey: 1 }, unique: true, partialFilterExpression: { idempotencyKey: { $exists: true } } }
29
+ ];
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ automationRuns
33
+ });
@@ -0,0 +1,10 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const automationRuns = [
3
+ { key: { automationId: 1, createdAt: -1 } },
4
+ { key: { ownerId: 1, createdAt: -1 } },
5
+ { key: { status: 1, createdAt: 1 } },
6
+ { key: { automationId: 1, idempotencyKey: 1 }, unique: true, partialFilterExpression: { idempotencyKey: { $exists: true } } }
7
+ ];
8
+ export {
9
+ automationRuns
10
+ };
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const automations: IndexDescription[];
@@ -16,16 +16,16 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agentic_jobs_exports = {};
20
- __export(agentic_jobs_exports, {
21
- agenticJobs: () => agenticJobs
19
+ var automations_exports = {};
20
+ __export(automations_exports, {
21
+ automations: () => automations
22
22
  });
23
- module.exports = __toCommonJS(agentic_jobs_exports);
24
- const agenticJobs = [
23
+ module.exports = __toCommonJS(automations_exports);
24
+ const automations = [
25
25
  { key: { enabled: 1, nextRunAt: 1 } },
26
26
  { key: { ownerId: 1, createdAt: -1 } }
27
27
  ];
28
28
  // Annotate the CommonJS export names for ESM import in node:
29
29
  0 && (module.exports = {
30
- agenticJobs
30
+ automations
31
31
  });
@@ -1,8 +1,8 @@
1
1
  import "../../chunk-CF3WOMB3.mjs";
2
- const agenticJobs = [
2
+ const automations = [
3
3
  { key: { enabled: 1, nextRunAt: 1 } },
4
4
  { key: { ownerId: 1, createdAt: -1 } }
5
5
  ];
6
6
  export {
7
- agenticJobs
7
+ automations
8
8
  };
@@ -29,8 +29,9 @@ var import_agent_actions = require("./agent-actions");
29
29
  var import_agent_traces = require("./agent-traces");
30
30
  var import_workspace_items = require("./workspace-items");
31
31
  var import_mcp_servers = require("./mcp-servers");
32
- var import_agentic_jobs = require("./agentic-jobs");
33
- var import_agentic_job_runs = require("./agentic-job-runs");
32
+ var import_automations = require("./automations");
33
+ var import_automation_runs = require("./automation-runs");
34
+ var import_revoked_tokens = require("./revoked-tokens");
34
35
  const indexes = {
35
36
  llm_calls: import_llm_calls.llmCalls,
36
37
  chats: import_chats.chats,
@@ -39,8 +40,9 @@ const indexes = {
39
40
  agent_traces: import_agent_traces.agentTraces,
40
41
  workspace_items: import_workspace_items.workspaceItems,
41
42
  mcp_servers: import_mcp_servers.mcpServers,
42
- agentic_jobs: import_agentic_jobs.agenticJobs,
43
- agentic_job_runs: import_agentic_job_runs.agenticJobRuns
43
+ automations: import_automations.automations,
44
+ automation_runs: import_automation_runs.automationRuns,
45
+ revoked_tokens: import_revoked_tokens.revokedTokens
44
46
  };
45
47
  async function ensureIndexes(db) {
46
48
  const created = {};
@@ -6,8 +6,9 @@ import { agentActions } from "./agent-actions";
6
6
  import { agentTraces } from "./agent-traces";
7
7
  import { workspaceItems } from "./workspace-items";
8
8
  import { mcpServers } from "./mcp-servers";
9
- import { agenticJobs } from "./agentic-jobs";
10
- import { agenticJobRuns } from "./agentic-job-runs";
9
+ import { automations } from "./automations";
10
+ import { automationRuns } from "./automation-runs";
11
+ import { revokedTokens } from "./revoked-tokens";
11
12
  const indexes = {
12
13
  llm_calls: llmCalls,
13
14
  chats,
@@ -16,8 +17,9 @@ const indexes = {
16
17
  agent_traces: agentTraces,
17
18
  workspace_items: workspaceItems,
18
19
  mcp_servers: mcpServers,
19
- agentic_jobs: agenticJobs,
20
- agentic_job_runs: agenticJobRuns
20
+ automations,
21
+ automation_runs: automationRuns,
22
+ revoked_tokens: revokedTokens
21
23
  };
22
24
  async function ensureIndexes(db) {
23
25
  const created = {};
@@ -0,0 +1,2 @@
1
+ import { IndexDescription } from 'mongodb';
2
+ export declare const revokedTokens: IndexDescription[];
@@ -16,17 +16,16 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agentic_job_runs_exports = {};
20
- __export(agentic_job_runs_exports, {
21
- agenticJobRuns: () => agenticJobRuns
19
+ var revoked_tokens_exports = {};
20
+ __export(revoked_tokens_exports, {
21
+ revokedTokens: () => revokedTokens
22
22
  });
23
- module.exports = __toCommonJS(agentic_job_runs_exports);
24
- const agenticJobRuns = [
25
- { key: { jobId: 1, createdAt: -1 } },
26
- { key: { ownerId: 1, createdAt: -1 } },
27
- { key: { status: 1, createdAt: 1 } }
23
+ module.exports = __toCommonJS(revoked_tokens_exports);
24
+ const revokedTokens = [
25
+ { key: { jti: 1 }, unique: true },
26
+ { key: { expiresAt: 1 }, expireAfterSeconds: 0 }
28
27
  ];
29
28
  // Annotate the CommonJS export names for ESM import in node:
30
29
  0 && (module.exports = {
31
- agenticJobRuns
30
+ revokedTokens
32
31
  });
@@ -0,0 +1,8 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const revokedTokens = [
3
+ { key: { jti: 1 }, unique: true },
4
+ { key: { expiresAt: 1 }, expireAfterSeconds: 0 }
5
+ ];
6
+ export {
7
+ revokedTokens
8
+ };
@@ -0,0 +1,12 @@
1
+ import { Db } from 'mongodb';
2
+ export interface AutomationsMigrationOptions {
3
+ dryRun?: boolean;
4
+ }
5
+ export interface AutomationsMigrationReport {
6
+ dryRun: boolean;
7
+ renamedCollections: string[];
8
+ triggersCreated: number;
9
+ runsUpdated: number;
10
+ droppedIndexes: string[];
11
+ }
12
+ export declare function migrateAutomations(db: Db, options?: AutomationsMigrationOptions): Promise<AutomationsMigrationReport>;
@@ -0,0 +1,70 @@
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 automations_exports = {};
20
+ __export(automations_exports, {
21
+ migrateAutomations: () => migrateAutomations
22
+ });
23
+ module.exports = __toCommonJS(automations_exports);
24
+ var import_indexes = require("../indexes");
25
+ const RENAMES = [
26
+ ["agentic_jobs", "automations"],
27
+ ["agentic_job_runs", "automation_runs"]
28
+ ];
29
+ const OLD_RUN_INDEX = "jobId_1_createdAt_-1";
30
+ const exists = async (db, name) => (await db.listCollections({ name }).toArray()).length > 0;
31
+ async function migrateAutomations(db, options = {}) {
32
+ const dryRun = Boolean(options.dryRun);
33
+ const report = { dryRun, renamedCollections: [], triggersCreated: 0, runsUpdated: 0, droppedIndexes: [] };
34
+ for (const [from, to] of RENAMES) {
35
+ if (!await exists(db, from)) continue;
36
+ if (await exists(db, to)) throw new Error(`Cannot rename ${from} to ${to} because ${to} already exists`);
37
+ if (!dryRun) await db.renameCollection(from, to);
38
+ report.renamedCollections.push(`${from} -> ${to}`);
39
+ }
40
+ const automations = db.collection(dryRun && report.renamedCollections.length ? "agentic_jobs" : "automations");
41
+ const runs = db.collection(dryRun && report.renamedCollections.length ? "agentic_job_runs" : "automation_runs");
42
+ const withoutTrigger = { trigger: { $exists: false }, recurrence: { $exists: true } };
43
+ const withJobId = { jobId: { $exists: true } };
44
+ if (dryRun) {
45
+ report.triggersCreated = await automations.countDocuments(withoutTrigger);
46
+ report.runsUpdated = await runs.countDocuments(withJobId);
47
+ } else {
48
+ const triggers = await automations.updateMany(withoutTrigger, [
49
+ { $set: { trigger: { type: "schedule", recurrence: "$recurrence", timezone: "$timezone" } } },
50
+ { $unset: ["recurrence", "timezone"] }
51
+ ]);
52
+ const moved = await runs.updateMany(withJobId, [
53
+ { $set: { automationId: "$jobId" } },
54
+ { $unset: "jobId" }
55
+ ]);
56
+ report.triggersCreated = triggers.modifiedCount;
57
+ report.runsUpdated = moved.modifiedCount;
58
+ }
59
+ const indexes = await runs.indexes().catch(() => []);
60
+ if (indexes.some((index) => index.name === OLD_RUN_INDEX)) {
61
+ if (!dryRun) await runs.dropIndex(OLD_RUN_INDEX);
62
+ report.droppedIndexes.push(OLD_RUN_INDEX);
63
+ }
64
+ if (!dryRun) await (0, import_indexes.ensureIndexes)(db);
65
+ return report;
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ migrateAutomations
70
+ });
@@ -0,0 +1,47 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ import { ensureIndexes } from "../indexes";
3
+ const RENAMES = [
4
+ ["agentic_jobs", "automations"],
5
+ ["agentic_job_runs", "automation_runs"]
6
+ ];
7
+ const OLD_RUN_INDEX = "jobId_1_createdAt_-1";
8
+ const exists = async (db, name) => (await db.listCollections({ name }).toArray()).length > 0;
9
+ async function migrateAutomations(db, options = {}) {
10
+ const dryRun = Boolean(options.dryRun);
11
+ const report = { dryRun, renamedCollections: [], triggersCreated: 0, runsUpdated: 0, droppedIndexes: [] };
12
+ for (const [from, to] of RENAMES) {
13
+ if (!await exists(db, from)) continue;
14
+ if (await exists(db, to)) throw new Error(`Cannot rename ${from} to ${to} because ${to} already exists`);
15
+ if (!dryRun) await db.renameCollection(from, to);
16
+ report.renamedCollections.push(`${from} -> ${to}`);
17
+ }
18
+ const automations = db.collection(dryRun && report.renamedCollections.length ? "agentic_jobs" : "automations");
19
+ const runs = db.collection(dryRun && report.renamedCollections.length ? "agentic_job_runs" : "automation_runs");
20
+ const withoutTrigger = { trigger: { $exists: false }, recurrence: { $exists: true } };
21
+ const withJobId = { jobId: { $exists: true } };
22
+ if (dryRun) {
23
+ report.triggersCreated = await automations.countDocuments(withoutTrigger);
24
+ report.runsUpdated = await runs.countDocuments(withJobId);
25
+ } else {
26
+ const triggers = await automations.updateMany(withoutTrigger, [
27
+ { $set: { trigger: { type: "schedule", recurrence: "$recurrence", timezone: "$timezone" } } },
28
+ { $unset: ["recurrence", "timezone"] }
29
+ ]);
30
+ const moved = await runs.updateMany(withJobId, [
31
+ { $set: { automationId: "$jobId" } },
32
+ { $unset: "jobId" }
33
+ ]);
34
+ report.triggersCreated = triggers.modifiedCount;
35
+ report.runsUpdated = moved.modifiedCount;
36
+ }
37
+ const indexes = await runs.indexes().catch(() => []);
38
+ if (indexes.some((index) => index.name === OLD_RUN_INDEX)) {
39
+ if (!dryRun) await runs.dropIndex(OLD_RUN_INDEX);
40
+ report.droppedIndexes.push(OLD_RUN_INDEX);
41
+ }
42
+ if (!dryRun) await ensureIndexes(db);
43
+ return report;
44
+ }
45
+ export {
46
+ migrateAutomations
47
+ };
@@ -6,6 +6,7 @@ import { AgentTask } from '../services/tasks/entities/agent-task.entity.js';
6
6
  import { AgentAction } from '../services/tasks/entities/agent-action.entity.js';
7
7
  import { Tool, BaseParams } from '../tools/tool.js';
8
8
  import { SkillRunOptions } from '../skills/skill.js';
9
+ import { SelectableThinkingEffort } from '../clients/llm/llm-types.js';
9
10
  import { WeightedKeyword, ScoredTool } from './utils/rank-tools-by-keywords';
10
11
  import type { ToolCatalog } from './tool-catalog';
11
12
  import { Workspace } from './workspace';
@@ -15,6 +16,7 @@ export interface RunContext {
15
16
  task?: AgentTask;
16
17
  chat: Chat;
17
18
  chatOptions?: ChatSettingsProps;
19
+ thinkingEffort?: SelectableThinkingEffort;
18
20
  currentUser: CurrentUser;
19
21
  currentSession?: CurrentSession;
20
22
  currentMessage: string;
@@ -50,6 +50,7 @@ export declare class Agent {
50
50
  private readonly strictMode;
51
51
  private readonly fallbackModel?;
52
52
  private model?;
53
+ private thinkingEffort?;
53
54
  private _tools;
54
55
  private _internalMcps;
55
56
  private _mcps;
@@ -45,6 +45,7 @@ var import_tool_pipeline = require("./tool-pipeline");
45
45
  var import_native_tools = require("./native-tools");
46
46
  var import_tool_catalog = require("./tool-catalog");
47
47
  var import_llm_error = require("../clients/llm/llm-error.js");
48
+ var import_llm_types = require("../clients/llm/llm-types.js");
48
49
  var import_model_resolution = require("../clients/llm/model-resolution.js");
49
50
  const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
50
51
  const MCP_DESCRIPTION_CHARS = 300;
@@ -67,6 +68,7 @@ class Agent {
67
68
  strictMode;
68
69
  fallbackModel;
69
70
  model;
71
+ thinkingEffort;
70
72
  _tools;
71
73
  _internalMcps = [];
72
74
  _mcps = [];
@@ -173,6 +175,8 @@ class Agent {
173
175
  this.mcpTokens = mcpTokens ?? {};
174
176
  this.serviceToken = serviceToken;
175
177
  this.model = void 0;
178
+ this.thinkingEffort = void 0;
179
+ if (options?.thinkingEffort !== void 0 && !(0, import_llm_types.isSelectableThinkingEffort)(options.thinkingEffort)) throw new Error(`[AGENT] thinkingEffort must be one of ${import_llm_types.SELECTABLE_THINKING_EFFORTS.join(", ")}`);
176
180
  if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
177
181
  this.answerId = new import_mongodb.ObjectId().toString();
178
182
  const proceed = await this.preRunner(chatId);
@@ -260,6 +264,9 @@ class Agent {
260
264
  });
261
265
  this.currentChat.settings?.setModelProvider(this.model.provider);
262
266
  this.currentChat.settings?.setModelName(this.model.model);
267
+ if (this.chatOptions?.thinkingEffort) this.currentChat.settings?.setThinkingEffort(this.chatOptions.thinkingEffort);
268
+ const savedEffort = this.currentChat.settings?.thinkingEffort;
269
+ this.thinkingEffort = this.chatOptions?.thinkingEffort ?? ((0, import_llm_types.isSelectableThinkingEffort)(savedEffort) ? savedEffort : void 0);
263
270
  if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
264
271
  this.awaitingConfirmation = this.currentChat.state?.status === import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION;
265
272
  this.currentChat.state?.setStatus(import_agent_state.AgentStatus.PROCESSING);
@@ -863,6 +870,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
863
870
  task: this.currentChat.activeTask,
864
871
  chat: this.currentChat,
865
872
  chatOptions: this.chatOptions,
873
+ thinkingEffort: this.thinkingEffort,
866
874
  currentUser: this.currentUser,
867
875
  currentSession: this.currentSession,
868
876
  currentMessage: this.currentMessage,