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.
- package/README.md +9 -8
- package/dist/clients/llm/llm-client.js +6 -5
- package/dist/clients/llm/llm-client.mjs +6 -5
- package/dist/clients/llm/llm-types.d.ts +3 -0
- package/dist/clients/llm/llm-types.js +15 -0
- package/dist/clients/llm/llm-types.mjs +7 -0
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +3 -1
- package/dist/db/index.mjs +1 -0
- package/dist/db/indexes/automation-runs.d.ts +2 -0
- package/dist/db/indexes/automation-runs.js +33 -0
- package/dist/db/indexes/automation-runs.mjs +10 -0
- package/dist/db/indexes/automations.d.ts +2 -0
- package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
- package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
- package/dist/db/indexes/index.js +6 -4
- package/dist/db/indexes/index.mjs +6 -4
- package/dist/db/indexes/revoked-tokens.d.ts +2 -0
- package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
- package/dist/db/indexes/revoked-tokens.mjs +8 -0
- package/dist/db/migrations/automations.d.ts +12 -0
- package/dist/db/migrations/automations.js +70 -0
- package/dist/db/migrations/automations.mjs +47 -0
- package/dist/harness/agent-loop.d.ts +2 -0
- package/dist/harness/agent.d.ts +1 -0
- package/dist/harness/agent.js +8 -0
- package/dist/harness/agent.mjs +8 -0
- package/dist/loops/agi/loop.js +2 -1
- package/dist/loops/agi/loop.mjs +2 -1
- package/dist/loops/agi/skills/reasoning-engine.js +3 -2
- package/dist/loops/agi/skills/reasoning-engine.mjs +3 -2
- package/dist/loops/shared/skills/fast-responder.js +2 -2
- package/dist/loops/shared/skills/fast-responder.mjs +2 -2
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +22 -0
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
- package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
- package/dist/services/authentication/index.d.ts +1 -0
- package/dist/services/authentication/index.js +3 -1
- package/dist/services/authentication/index.mjs +1 -0
- package/dist/services/authentication/module.d.ts +4 -0
- package/dist/services/authentication/module.js +16 -2
- package/dist/services/authentication/module.mjs +13 -1
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
- package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
- package/dist/services/automations/entities/automation.entity.d.ts +38 -0
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
- package/dist/services/automations/entities/index.d.ts +4 -0
- package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
- package/dist/services/automations/entities/index.mjs +4 -0
- package/dist/services/automations/entities/trigger.d.ts +11 -0
- package/dist/services/automations/entities/trigger.js +49 -0
- package/dist/services/automations/entities/trigger.mjs +26 -0
- package/dist/services/automations/index.d.ts +5 -0
- package/dist/services/{agentic-jobs → automations}/index.js +9 -7
- package/dist/services/automations/index.mjs +5 -0
- package/dist/services/automations/module.d.ts +41 -0
- package/dist/services/automations/module.js +167 -0
- package/dist/services/automations/module.mjs +125 -0
- package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
- package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
- package/dist/services/automations/repositories/index.d.ts +2 -0
- package/dist/services/automations/repositories/index.js +24 -0
- package/dist/services/automations/repositories/index.mjs +2 -0
- package/dist/services/automations/runner/automation-runner.d.ts +49 -0
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
- 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
- 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
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
- 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
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
- package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
- 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
- package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
- 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
- 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
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
- 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
- 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
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
- 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
- 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
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
- 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
- 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
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
- 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
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
- 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
- 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
- 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
- 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
- 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
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
- package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
- package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
- package/dist/services/automations/utils/automation-event-error.js +37 -0
- package/dist/services/automations/utils/automation-event-error.mjs +14 -0
- package/dist/services/automations/utils/automation-fields.d.ts +14 -0
- package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
- package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
- package/dist/services/automations/utils/event-message.d.ts +1 -0
- package/dist/services/automations/utils/event-message.js +37 -0
- package/dist/services/automations/utils/event-message.mjs +14 -0
- package/dist/services/automations/utils/event-token.d.ts +18 -0
- package/dist/services/automations/utils/event-token.js +78 -0
- package/dist/services/automations/utils/event-token.mjs +43 -0
- package/dist/services/automations/utils/open-run.d.ts +14 -0
- package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
- package/dist/services/automations/utils/open-run.mjs +26 -0
- package/dist/services/automations/utils/previous-run.d.ts +4 -0
- package/dist/services/automations/utils/previous-run.js +42 -0
- package/dist/services/automations/utils/previous-run.mjs +19 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
- package/dist/services/automations/utils/settings.mjs +13 -0
- package/dist/services/chats/entities/chat-settings.entity.d.ts +5 -1
- package/dist/services/chats/entities/chat-settings.entity.js +10 -3
- package/dist/services/chats/entities/chat-settings.entity.mjs +10 -3
- package/dist/skills/skill.d.ts +2 -1
- package/dist/skills/skill.js +4 -3
- package/dist/skills/skill.mjs +4 -3
- package/docs/README.md +1 -1
- package/docs/agent.md +3 -2
- package/docs/authentication.md +18 -1
- package/docs/automations.md +341 -0
- package/docs/chats.md +1 -1
- package/docs/configuration.md +8 -7
- package/docs/harness.md +1 -1
- package/docs/integration-guide.md +22 -18
- package/docs/llms.txt +1 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/skills.md +1 -1
- package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
- package/examples/automations/create-event-automation.ts +24 -0
- package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
- package/examples/automations/list-automations.ts +25 -0
- package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
- package/examples/automations/receive-automation-event.ts +26 -0
- package/examples/automations/revoke-automation-event-token.ts +25 -0
- package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
- package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
- package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
- package/package.json +14 -13
- package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
- package/dist/db/indexes/agentic-job-runs.mjs +0 -9
- package/dist/db/indexes/agentic-jobs.d.ts +0 -2
- package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
- package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
- package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
- package/dist/services/agentic-jobs/entities/index.mjs +0 -3
- package/dist/services/agentic-jobs/index.d.ts +0 -4
- package/dist/services/agentic-jobs/index.mjs +0 -4
- package/dist/services/agentic-jobs/module.d.ts +0 -31
- package/dist/services/agentic-jobs/module.js +0 -132
- package/dist/services/agentic-jobs/module.mjs +0 -95
- package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
- package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
- package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
- package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
- package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
- package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
- package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
- package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
- package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
- package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
- package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
- package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
- package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
- package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
- package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
- package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
- package/docs/agentic-jobs.md +0 -217
- package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var module_exports = {};
|
|
20
|
-
__export(module_exports, {
|
|
21
|
-
attachAgenticJobRunChat: () => attachAgenticJobRunChat,
|
|
22
|
-
claimDueAgenticJobs: () => claimDueAgenticJobs,
|
|
23
|
-
createAgenticJob: () => createAgenticJob,
|
|
24
|
-
deleteAgenticJob: () => deleteAgenticJob,
|
|
25
|
-
finishAgenticJobRun: () => finishAgenticJobRun,
|
|
26
|
-
getAgenticJobById: () => getAgenticJobById,
|
|
27
|
-
listAgenticJobRunsByJob: () => listAgenticJobRunsByJob,
|
|
28
|
-
listAgenticJobRunsByUser: () => listAgenticJobRunsByUser,
|
|
29
|
-
listAgenticJobsByUser: () => listAgenticJobsByUser,
|
|
30
|
-
previewAgenticJobRuns: () => previewAgenticJobRuns,
|
|
31
|
-
renewAgenticJobLease: () => renewAgenticJobLease,
|
|
32
|
-
startAgenticJobRun: () => startAgenticJobRun,
|
|
33
|
-
syncAgenticJobRun: () => syncAgenticJobRun,
|
|
34
|
-
syncAgenticJobRuns: () => syncAgenticJobRuns,
|
|
35
|
-
updateAgenticJob: () => updateAgenticJob
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(module_exports);
|
|
38
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
39
|
-
var import_tsyringe = require("tsyringe");
|
|
40
|
-
var import_create_agentic_job = require("./use-cases/create-agentic-job.use-case");
|
|
41
|
-
var import_update_agentic_job = require("./use-cases/update-agentic-job.use-case");
|
|
42
|
-
var import_get_agentic_job_by_id = require("./use-cases/get-agentic-job-by-id.use-case");
|
|
43
|
-
var import_list_agentic_jobs_by_user = require("./use-cases/list-agentic-jobs-by-user.use-case");
|
|
44
|
-
var import_delete_agentic_job = require("./use-cases/delete-agentic-job.use-case");
|
|
45
|
-
var import_preview_agentic_job_runs = require("./use-cases/preview-agentic-job-runs.use-case");
|
|
46
|
-
var import_list_agentic_job_runs_by_job = require("./use-cases/list-agentic-job-runs-by-job.use-case");
|
|
47
|
-
var import_list_agentic_job_runs_by_user = require("./use-cases/list-agentic-job-runs-by-user.use-case");
|
|
48
|
-
var import_claim_due_agentic_jobs = require("./use-cases/claim-due-agentic-jobs.use-case");
|
|
49
|
-
var import_start_agentic_job_run = require("./use-cases/start-agentic-job-run.use-case");
|
|
50
|
-
var import_finish_agentic_job_run = require("./use-cases/finish-agentic-job-run.use-case");
|
|
51
|
-
var import_sync_agentic_job_run = require("./use-cases/sync-agentic-job-run.use-case");
|
|
52
|
-
var import_sync_agentic_job_runs = require("./use-cases/sync-agentic-job-runs.use-case");
|
|
53
|
-
var import_attach_agentic_job_run_chat = require("./use-cases/attach-agentic-job-run-chat.use-case");
|
|
54
|
-
var import_renew_agentic_job_lease = require("./use-cases/renew-agentic-job-lease.use-case");
|
|
55
|
-
async function createAgenticJob(props) {
|
|
56
|
-
const createAgenticJobUseCase = import_tsyringe.container.resolve(import_create_agentic_job.CreateAgenticJobUseCase);
|
|
57
|
-
return createAgenticJobUseCase.execute(props);
|
|
58
|
-
}
|
|
59
|
-
async function updateAgenticJob(props) {
|
|
60
|
-
const updateAgenticJobUseCase = import_tsyringe.container.resolve(import_update_agentic_job.UpdateAgenticJobUseCase);
|
|
61
|
-
return updateAgenticJobUseCase.execute(props);
|
|
62
|
-
}
|
|
63
|
-
async function getAgenticJobById(props) {
|
|
64
|
-
const getAgenticJobByIdUseCase = import_tsyringe.container.resolve(import_get_agentic_job_by_id.GetAgenticJobByIdUseCase);
|
|
65
|
-
return getAgenticJobByIdUseCase.execute(props);
|
|
66
|
-
}
|
|
67
|
-
async function listAgenticJobsByUser(props) {
|
|
68
|
-
const listAgenticJobsByUserUseCase = import_tsyringe.container.resolve(import_list_agentic_jobs_by_user.ListAgenticJobsByUserUseCase);
|
|
69
|
-
return listAgenticJobsByUserUseCase.execute(props);
|
|
70
|
-
}
|
|
71
|
-
async function deleteAgenticJob(props) {
|
|
72
|
-
const deleteAgenticJobUseCase = import_tsyringe.container.resolve(import_delete_agentic_job.DeleteAgenticJobUseCase);
|
|
73
|
-
return deleteAgenticJobUseCase.execute(props);
|
|
74
|
-
}
|
|
75
|
-
async function previewAgenticJobRuns(props) {
|
|
76
|
-
const previewAgenticJobRunsUseCase = import_tsyringe.container.resolve(import_preview_agentic_job_runs.PreviewAgenticJobRunsUseCase);
|
|
77
|
-
return previewAgenticJobRunsUseCase.execute(props);
|
|
78
|
-
}
|
|
79
|
-
async function listAgenticJobRunsByJob(props) {
|
|
80
|
-
const listAgenticJobRunsByJobUseCase = import_tsyringe.container.resolve(import_list_agentic_job_runs_by_job.ListAgenticJobRunsByJobUseCase);
|
|
81
|
-
return listAgenticJobRunsByJobUseCase.execute(props);
|
|
82
|
-
}
|
|
83
|
-
async function listAgenticJobRunsByUser(props) {
|
|
84
|
-
const listAgenticJobRunsByUserUseCase = import_tsyringe.container.resolve(import_list_agentic_job_runs_by_user.ListAgenticJobRunsByUserUseCase);
|
|
85
|
-
return listAgenticJobRunsByUserUseCase.execute(props);
|
|
86
|
-
}
|
|
87
|
-
async function claimDueAgenticJobs(props) {
|
|
88
|
-
const claimDueAgenticJobsUseCase = import_tsyringe.container.resolve(import_claim_due_agentic_jobs.ClaimDueAgenticJobsUseCase);
|
|
89
|
-
return claimDueAgenticJobsUseCase.execute(props);
|
|
90
|
-
}
|
|
91
|
-
async function startAgenticJobRun(props) {
|
|
92
|
-
const startAgenticJobRunUseCase = import_tsyringe.container.resolve(import_start_agentic_job_run.StartAgenticJobRunUseCase);
|
|
93
|
-
return startAgenticJobRunUseCase.execute(props);
|
|
94
|
-
}
|
|
95
|
-
async function finishAgenticJobRun(props) {
|
|
96
|
-
const finishAgenticJobRunUseCase = import_tsyringe.container.resolve(import_finish_agentic_job_run.FinishAgenticJobRunUseCase);
|
|
97
|
-
return finishAgenticJobRunUseCase.execute(props);
|
|
98
|
-
}
|
|
99
|
-
async function syncAgenticJobRun(props) {
|
|
100
|
-
const syncAgenticJobRunUseCase = import_tsyringe.container.resolve(import_sync_agentic_job_run.SyncAgenticJobRunUseCase);
|
|
101
|
-
return syncAgenticJobRunUseCase.execute(props);
|
|
102
|
-
}
|
|
103
|
-
async function syncAgenticJobRuns(props = {}) {
|
|
104
|
-
const syncAgenticJobRunsUseCase = import_tsyringe.container.resolve(import_sync_agentic_job_runs.SyncAgenticJobRunsUseCase);
|
|
105
|
-
return syncAgenticJobRunsUseCase.execute(props);
|
|
106
|
-
}
|
|
107
|
-
async function attachAgenticJobRunChat(props) {
|
|
108
|
-
const attachAgenticJobRunChatUseCase = import_tsyringe.container.resolve(import_attach_agentic_job_run_chat.AttachAgenticJobRunChatUseCase);
|
|
109
|
-
return attachAgenticJobRunChatUseCase.execute(props);
|
|
110
|
-
}
|
|
111
|
-
async function renewAgenticJobLease(props) {
|
|
112
|
-
const renewAgenticJobLeaseUseCase = import_tsyringe.container.resolve(import_renew_agentic_job_lease.RenewAgenticJobLeaseUseCase);
|
|
113
|
-
return renewAgenticJobLeaseUseCase.execute(props);
|
|
114
|
-
}
|
|
115
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
-
0 && (module.exports = {
|
|
117
|
-
attachAgenticJobRunChat,
|
|
118
|
-
claimDueAgenticJobs,
|
|
119
|
-
createAgenticJob,
|
|
120
|
-
deleteAgenticJob,
|
|
121
|
-
finishAgenticJobRun,
|
|
122
|
-
getAgenticJobById,
|
|
123
|
-
listAgenticJobRunsByJob,
|
|
124
|
-
listAgenticJobRunsByUser,
|
|
125
|
-
listAgenticJobsByUser,
|
|
126
|
-
previewAgenticJobRuns,
|
|
127
|
-
renewAgenticJobLease,
|
|
128
|
-
startAgenticJobRun,
|
|
129
|
-
syncAgenticJobRun,
|
|
130
|
-
syncAgenticJobRuns,
|
|
131
|
-
updateAgenticJob
|
|
132
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { container } from "tsyringe";
|
|
4
|
-
import { CreateAgenticJobUseCase } from "./use-cases/create-agentic-job.use-case";
|
|
5
|
-
import { UpdateAgenticJobUseCase } from "./use-cases/update-agentic-job.use-case";
|
|
6
|
-
import { GetAgenticJobByIdUseCase } from "./use-cases/get-agentic-job-by-id.use-case";
|
|
7
|
-
import { ListAgenticJobsByUserUseCase } from "./use-cases/list-agentic-jobs-by-user.use-case";
|
|
8
|
-
import { DeleteAgenticJobUseCase } from "./use-cases/delete-agentic-job.use-case";
|
|
9
|
-
import { PreviewAgenticJobRunsUseCase } from "./use-cases/preview-agentic-job-runs.use-case";
|
|
10
|
-
import { ListAgenticJobRunsByJobUseCase } from "./use-cases/list-agentic-job-runs-by-job.use-case";
|
|
11
|
-
import { ListAgenticJobRunsByUserUseCase } from "./use-cases/list-agentic-job-runs-by-user.use-case";
|
|
12
|
-
import { ClaimDueAgenticJobsUseCase } from "./use-cases/claim-due-agentic-jobs.use-case";
|
|
13
|
-
import { StartAgenticJobRunUseCase } from "./use-cases/start-agentic-job-run.use-case";
|
|
14
|
-
import { FinishAgenticJobRunUseCase } from "./use-cases/finish-agentic-job-run.use-case";
|
|
15
|
-
import { SyncAgenticJobRunUseCase } from "./use-cases/sync-agentic-job-run.use-case";
|
|
16
|
-
import { SyncAgenticJobRunsUseCase } from "./use-cases/sync-agentic-job-runs.use-case";
|
|
17
|
-
import { AttachAgenticJobRunChatUseCase } from "./use-cases/attach-agentic-job-run-chat.use-case";
|
|
18
|
-
import { RenewAgenticJobLeaseUseCase } from "./use-cases/renew-agentic-job-lease.use-case";
|
|
19
|
-
async function createAgenticJob(props) {
|
|
20
|
-
const createAgenticJobUseCase = container.resolve(CreateAgenticJobUseCase);
|
|
21
|
-
return createAgenticJobUseCase.execute(props);
|
|
22
|
-
}
|
|
23
|
-
async function updateAgenticJob(props) {
|
|
24
|
-
const updateAgenticJobUseCase = container.resolve(UpdateAgenticJobUseCase);
|
|
25
|
-
return updateAgenticJobUseCase.execute(props);
|
|
26
|
-
}
|
|
27
|
-
async function getAgenticJobById(props) {
|
|
28
|
-
const getAgenticJobByIdUseCase = container.resolve(GetAgenticJobByIdUseCase);
|
|
29
|
-
return getAgenticJobByIdUseCase.execute(props);
|
|
30
|
-
}
|
|
31
|
-
async function listAgenticJobsByUser(props) {
|
|
32
|
-
const listAgenticJobsByUserUseCase = container.resolve(ListAgenticJobsByUserUseCase);
|
|
33
|
-
return listAgenticJobsByUserUseCase.execute(props);
|
|
34
|
-
}
|
|
35
|
-
async function deleteAgenticJob(props) {
|
|
36
|
-
const deleteAgenticJobUseCase = container.resolve(DeleteAgenticJobUseCase);
|
|
37
|
-
return deleteAgenticJobUseCase.execute(props);
|
|
38
|
-
}
|
|
39
|
-
async function previewAgenticJobRuns(props) {
|
|
40
|
-
const previewAgenticJobRunsUseCase = container.resolve(PreviewAgenticJobRunsUseCase);
|
|
41
|
-
return previewAgenticJobRunsUseCase.execute(props);
|
|
42
|
-
}
|
|
43
|
-
async function listAgenticJobRunsByJob(props) {
|
|
44
|
-
const listAgenticJobRunsByJobUseCase = container.resolve(ListAgenticJobRunsByJobUseCase);
|
|
45
|
-
return listAgenticJobRunsByJobUseCase.execute(props);
|
|
46
|
-
}
|
|
47
|
-
async function listAgenticJobRunsByUser(props) {
|
|
48
|
-
const listAgenticJobRunsByUserUseCase = container.resolve(ListAgenticJobRunsByUserUseCase);
|
|
49
|
-
return listAgenticJobRunsByUserUseCase.execute(props);
|
|
50
|
-
}
|
|
51
|
-
async function claimDueAgenticJobs(props) {
|
|
52
|
-
const claimDueAgenticJobsUseCase = container.resolve(ClaimDueAgenticJobsUseCase);
|
|
53
|
-
return claimDueAgenticJobsUseCase.execute(props);
|
|
54
|
-
}
|
|
55
|
-
async function startAgenticJobRun(props) {
|
|
56
|
-
const startAgenticJobRunUseCase = container.resolve(StartAgenticJobRunUseCase);
|
|
57
|
-
return startAgenticJobRunUseCase.execute(props);
|
|
58
|
-
}
|
|
59
|
-
async function finishAgenticJobRun(props) {
|
|
60
|
-
const finishAgenticJobRunUseCase = container.resolve(FinishAgenticJobRunUseCase);
|
|
61
|
-
return finishAgenticJobRunUseCase.execute(props);
|
|
62
|
-
}
|
|
63
|
-
async function syncAgenticJobRun(props) {
|
|
64
|
-
const syncAgenticJobRunUseCase = container.resolve(SyncAgenticJobRunUseCase);
|
|
65
|
-
return syncAgenticJobRunUseCase.execute(props);
|
|
66
|
-
}
|
|
67
|
-
async function syncAgenticJobRuns(props = {}) {
|
|
68
|
-
const syncAgenticJobRunsUseCase = container.resolve(SyncAgenticJobRunsUseCase);
|
|
69
|
-
return syncAgenticJobRunsUseCase.execute(props);
|
|
70
|
-
}
|
|
71
|
-
async function attachAgenticJobRunChat(props) {
|
|
72
|
-
const attachAgenticJobRunChatUseCase = container.resolve(AttachAgenticJobRunChatUseCase);
|
|
73
|
-
return attachAgenticJobRunChatUseCase.execute(props);
|
|
74
|
-
}
|
|
75
|
-
async function renewAgenticJobLease(props) {
|
|
76
|
-
const renewAgenticJobLeaseUseCase = container.resolve(RenewAgenticJobLeaseUseCase);
|
|
77
|
-
return renewAgenticJobLeaseUseCase.execute(props);
|
|
78
|
-
}
|
|
79
|
-
export {
|
|
80
|
-
attachAgenticJobRunChat,
|
|
81
|
-
claimDueAgenticJobs,
|
|
82
|
-
createAgenticJob,
|
|
83
|
-
deleteAgenticJob,
|
|
84
|
-
finishAgenticJobRun,
|
|
85
|
-
getAgenticJobById,
|
|
86
|
-
listAgenticJobRunsByJob,
|
|
87
|
-
listAgenticJobRunsByUser,
|
|
88
|
-
listAgenticJobsByUser,
|
|
89
|
-
previewAgenticJobRuns,
|
|
90
|
-
renewAgenticJobLease,
|
|
91
|
-
startAgenticJobRun,
|
|
92
|
-
syncAgenticJobRun,
|
|
93
|
-
syncAgenticJobRuns,
|
|
94
|
-
updateAgenticJob
|
|
95
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MongoRepository, QueryOptions } from '../../../common/repositories/index.js';
|
|
2
|
-
import { AgenticJobRun, AgenticJobRunProps, AgenticJobRunStatus } from '../entities';
|
|
3
|
-
export declare class AgenticJobRunRepository {
|
|
4
|
-
readonly _: MongoRepository<AgenticJobRunProps>;
|
|
5
|
-
create(run: AgenticJobRun): Promise<AgenticJobRun>;
|
|
6
|
-
update(run: AgenticJobRun): Promise<AgenticJobRunProps | null>;
|
|
7
|
-
findById(id: string): Promise<AgenticJobRunProps | null>;
|
|
8
|
-
findByJob(jobId: string, options?: QueryOptions): Promise<AgenticJobRunProps[]>;
|
|
9
|
-
findByOwner(ownerId: string, options?: QueryOptions, status?: AgenticJobRunStatus): Promise<AgenticJobRunProps[]>;
|
|
10
|
-
findByStatus(status: AgenticJobRunStatus, limit: number): Promise<AgenticJobRunProps[]>;
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MongoRepository, QueryOptions } from '../../../common/repositories/index.js';
|
|
2
|
-
import { AgenticJob, AgenticJobProps, AgenticJobRunStatus } 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 AgenticJobRepository {
|
|
11
|
-
readonly _: MongoRepository<AgenticJobProps>;
|
|
12
|
-
create(job: AgenticJob): Promise<AgenticJob>;
|
|
13
|
-
update(job: AgenticJob, options?: {
|
|
14
|
-
expectedVersion?: number;
|
|
15
|
-
}): Promise<AgenticJobProps | null>;
|
|
16
|
-
findById(id: string): Promise<AgenticJobProps | null>;
|
|
17
|
-
findByOwner(ownerId: string, options?: QueryOptions): Promise<AgenticJobProps[]>;
|
|
18
|
-
deleteById(id: string): Promise<number>;
|
|
19
|
-
findDue(now: Date, limit: number): Promise<AgenticJobProps[]>;
|
|
20
|
-
claim(params: ClaimParams): Promise<AgenticJobProps | null>;
|
|
21
|
-
claimManual(params: Omit<ClaimParams, 'nextRunAt'>): Promise<AgenticJobProps | null>;
|
|
22
|
-
setActiveRun(id: string, workerId: string, runId: string): Promise<AgenticJobProps | null>;
|
|
23
|
-
settleRun(id: string, runId: string, status: AgenticJobRunStatus, at: Date): Promise<AgenticJobProps | null>;
|
|
24
|
-
renewLease(id: string, workerId: string, until: Date): Promise<AgenticJobProps | null>;
|
|
25
|
-
release(id: string, workerId: string, result: Pick<AgenticJobProps, 'lastRunAt' | 'lastRunStatus' | 'activeRunId'>): Promise<AgenticJobProps | null>;
|
|
26
|
-
private unlocked;
|
|
27
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
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 { AgenticJobProps, AgenticJobRunProps } from '../entities';
|
|
5
|
-
export interface AgenticJobContext {
|
|
6
|
-
job: AgenticJobProps;
|
|
7
|
-
currentUser: CurrentUser;
|
|
8
|
-
}
|
|
9
|
-
export type AgenticJobAgentConfig = Partial<AgentOptions> | ((context: AgenticJobContext) => Partial<AgentOptions> | Promise<Partial<AgentOptions>>);
|
|
10
|
-
export interface AgenticJobRunFinished {
|
|
11
|
-
job: AgenticJobProps;
|
|
12
|
-
run: AgenticJobRunProps;
|
|
13
|
-
chat?: Chat;
|
|
14
|
-
}
|
|
15
|
-
export interface AgenticJobRunnerOptions {
|
|
16
|
-
agent?: AgenticJobAgentConfig;
|
|
17
|
-
intervalMs?: number;
|
|
18
|
-
leaseMs?: number;
|
|
19
|
-
maxConcurrentRuns?: number;
|
|
20
|
-
stopTimeoutMs?: number;
|
|
21
|
-
workerId?: string;
|
|
22
|
-
onRunFinished?: (event: AgenticJobRunFinished) => void | Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
export declare class AgenticJobRunner {
|
|
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 wake?;
|
|
33
|
-
constructor(options?: AgenticJobRunnerOptions);
|
|
34
|
-
start(): void;
|
|
35
|
-
stop(): Promise<void>;
|
|
36
|
-
tick(): Promise<void>;
|
|
37
|
-
runNow(params: {
|
|
38
|
-
jobId: string;
|
|
39
|
-
}): Promise<{
|
|
40
|
-
run: AgenticJobRunProps;
|
|
41
|
-
}>;
|
|
42
|
-
private loop;
|
|
43
|
-
private track;
|
|
44
|
-
private execute;
|
|
45
|
-
private runAgent;
|
|
46
|
-
private notify;
|
|
47
|
-
}
|
|
48
|
-
export declare function createAgenticJobRunner(options?: AgenticJobRunnerOptions): AgenticJobRunner;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJobRun } from "../entities";
|
|
8
|
-
import { AgenticJobRunRepository } from "../repositories";
|
|
9
|
-
let AttachAgenticJobRunChatUseCase = class extends BaseUseCase {
|
|
10
|
-
constructor(agenticJobRunRepository) {
|
|
11
|
-
super();
|
|
12
|
-
this.agenticJobRunRepository = agenticJobRunRepository;
|
|
13
|
-
}
|
|
14
|
-
agenticJobRunRepository;
|
|
15
|
-
async execute(params) {
|
|
16
|
-
const { runId, chatId } = params;
|
|
17
|
-
const run = await this.agenticJobRunRepository.findById(runId);
|
|
18
|
-
if (!run) return { data: null };
|
|
19
|
-
const saved = await this.agenticJobRunRepository.update(AgenticJobRun.fromJSON({ ...run, chatId }));
|
|
20
|
-
return { data: saved };
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
AttachAgenticJobRunChatUseCase = __decorateClass([
|
|
24
|
-
autoInjectable(),
|
|
25
|
-
__decorateParam(0, inject(AgenticJobRunRepository))
|
|
26
|
-
], AttachAgenticJobRunChatUseCase);
|
|
27
|
-
export {
|
|
28
|
-
AttachAgenticJobRunChatUseCase
|
|
29
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
-
import { AgenticJobProps, AgenticJobRunProps } from '../entities';
|
|
3
|
-
import { AgenticJobRepository, AgenticJobRunRepository } from '../repositories';
|
|
4
|
-
import { SyncAgenticJobRunUseCase } from './sync-agentic-job-run.use-case';
|
|
5
|
-
export interface Params extends BaseUseCaseParams {
|
|
6
|
-
workerId: string;
|
|
7
|
-
limit?: number;
|
|
8
|
-
leaseMs?: number;
|
|
9
|
-
now?: Date;
|
|
10
|
-
}
|
|
11
|
-
export interface ClaimedRun {
|
|
12
|
-
job: AgenticJobProps;
|
|
13
|
-
run: AgenticJobRunProps;
|
|
14
|
-
}
|
|
15
|
-
export interface Output extends BaseUseCaseOutput {
|
|
16
|
-
data: {
|
|
17
|
-
claimed: ClaimedRun[];
|
|
18
|
-
skipped: ClaimedRun[];
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export declare class ClaimDueAgenticJobsUseCase extends BaseUseCase<Params, Output> {
|
|
22
|
-
private readonly agenticJobRepository?;
|
|
23
|
-
private readonly agenticJobRunRepository?;
|
|
24
|
-
private readonly syncRun?;
|
|
25
|
-
private readonly log;
|
|
26
|
-
constructor(agenticJobRepository?: AgenticJobRepository | undefined, agenticJobRunRepository?: AgenticJobRunRepository | undefined, syncRun?: SyncAgenticJobRunUseCase | undefined);
|
|
27
|
-
execute(params: Params): Promise<Output>;
|
|
28
|
-
private previousRun;
|
|
29
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { Logger } from "../../../common/logger/index.js";
|
|
7
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
8
|
-
import { AgenticJobRun } from "../entities";
|
|
9
|
-
import { AgenticJobRepository, AgenticJobRunRepository } from "../repositories";
|
|
10
|
-
import { computeNextRun } from "../utils/next-run";
|
|
11
|
-
import { openRun } from "../utils/open-run";
|
|
12
|
-
import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
13
|
-
import { SyncAgenticJobRunUseCase, LOST_WORKER_MESSAGE } from "./sync-agentic-job-run.use-case";
|
|
14
|
-
const DEFAULT_LIMIT = 10;
|
|
15
|
-
let ClaimDueAgenticJobsUseCase = class extends BaseUseCase {
|
|
16
|
-
constructor(agenticJobRepository, agenticJobRunRepository, syncRun) {
|
|
17
|
-
super();
|
|
18
|
-
this.agenticJobRepository = agenticJobRepository;
|
|
19
|
-
this.agenticJobRunRepository = agenticJobRunRepository;
|
|
20
|
-
this.syncRun = syncRun;
|
|
21
|
-
}
|
|
22
|
-
agenticJobRepository;
|
|
23
|
-
agenticJobRunRepository;
|
|
24
|
-
syncRun;
|
|
25
|
-
log = new Logger();
|
|
26
|
-
async execute(params) {
|
|
27
|
-
const { workerId } = params;
|
|
28
|
-
if (!workerId) throw new Error("The id of the worker is required");
|
|
29
|
-
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
30
|
-
const leaseMs = params.leaseMs ?? defaultLeaseMs();
|
|
31
|
-
const due = await this.agenticJobRepository.findDue(now, params.limit ?? DEFAULT_LIMIT);
|
|
32
|
-
const claimed = [];
|
|
33
|
-
const skipped = [];
|
|
34
|
-
for (const candidate of due) {
|
|
35
|
-
const id = String(candidate._id);
|
|
36
|
-
const scheduledFor = candidate.nextRunAt ? new Date(candidate.nextRunAt) : void 0;
|
|
37
|
-
let nextRunAt = null;
|
|
38
|
-
try {
|
|
39
|
-
nextRunAt = computeNextRun(candidate.recurrence, candidate.timezone, now);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
this.log.error({ error: error?.message ?? error, jobId: id }, "[AGENTIC JOBS] The recurrence of a job cannot be calculated, skipping it");
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const job = await this.agenticJobRepository.claim({ id, workerId, now, leaseMs, nextRunAt: nextRunAt ?? void 0 });
|
|
45
|
-
if (!job) continue;
|
|
46
|
-
const pending = await this.previousRun(job, now);
|
|
47
|
-
if (pending) {
|
|
48
|
-
const run2 = await openRun(this.agenticJobRunRepository, { job, trigger: "schedule", status: "skipped", workerId, now, scheduledFor, skipReason: "The previous run is still waiting for the user" });
|
|
49
|
-
await this.agenticJobRepository.release(id, workerId, { activeRunId: pending._id });
|
|
50
|
-
skipped.push({ job, run: run2.toJSON() });
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const run = await openRun(this.agenticJobRunRepository, { job, trigger: "schedule", status: "running", workerId, now, scheduledFor });
|
|
54
|
-
await this.agenticJobRepository.setActiveRun(id, workerId, String(run._id));
|
|
55
|
-
claimed.push({ job, run: run.toJSON() });
|
|
56
|
-
}
|
|
57
|
-
return { data: { claimed, skipped } };
|
|
58
|
-
}
|
|
59
|
-
async previousRun(job, now) {
|
|
60
|
-
if (!job.activeRunId) return null;
|
|
61
|
-
const previous = await this.agenticJobRunRepository.findById(String(job.activeRunId));
|
|
62
|
-
if (!previous) return null;
|
|
63
|
-
if (previous.status === "running") {
|
|
64
|
-
const lost = AgenticJobRun.fromJSON({ ...previous, status: "failed", finishedAt: now, error: { code: "WORKER_LOST", message: LOST_WORKER_MESSAGE } });
|
|
65
|
-
await this.agenticJobRunRepository.update(lost);
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
if (previous.status !== "paused") return null;
|
|
69
|
-
const { data } = await this.syncRun.execute({ runId: String(previous._id), now });
|
|
70
|
-
return data?.status === "paused" ? data : null;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
ClaimDueAgenticJobsUseCase = __decorateClass([
|
|
74
|
-
autoInjectable(),
|
|
75
|
-
__decorateParam(0, inject(AgenticJobRepository)),
|
|
76
|
-
__decorateParam(1, inject(AgenticJobRunRepository)),
|
|
77
|
-
__decorateParam(2, inject(SyncAgenticJobRunUseCase))
|
|
78
|
-
], ClaimDueAgenticJobsUseCase);
|
|
79
|
-
export {
|
|
80
|
-
ClaimDueAgenticJobsUseCase
|
|
81
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
-
import { AgenticJobProps } from '../entities';
|
|
3
|
-
import { AgenticJobRepository } from '../repositories';
|
|
4
|
-
export interface Params extends BaseUseCaseParams {
|
|
5
|
-
payload?: AgenticJobProps;
|
|
6
|
-
}
|
|
7
|
-
export interface Output extends BaseUseCaseOutput {
|
|
8
|
-
data: AgenticJobProps;
|
|
9
|
-
}
|
|
10
|
-
export declare class CreateAgenticJobUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
-
private readonly agenticJobRepository?;
|
|
12
|
-
constructor(agenticJobRepository?: AgenticJobRepository | undefined);
|
|
13
|
-
execute(params: Params): Promise<Output>;
|
|
14
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJob } from "../entities";
|
|
8
|
-
import { AgenticJobRepository } from "../repositories";
|
|
9
|
-
import { readJobFields, assertModel } from "../utils/job-fields";
|
|
10
|
-
let CreateAgenticJobUseCase = class extends BaseUseCase {
|
|
11
|
-
constructor(agenticJobRepository) {
|
|
12
|
-
super();
|
|
13
|
-
this.agenticJobRepository = agenticJobRepository;
|
|
14
|
-
}
|
|
15
|
-
agenticJobRepository;
|
|
16
|
-
async execute(params) {
|
|
17
|
-
const { payload, currentUser } = params;
|
|
18
|
-
if (!currentUser?.userId) throw new Error("CurrentUser is required to create an agentic job");
|
|
19
|
-
const fields = readJobFields(payload, { complete: true });
|
|
20
|
-
assertModel(fields.modelProvider, fields.modelName);
|
|
21
|
-
const job = AgenticJob.fromJSON({
|
|
22
|
-
name: fields.name,
|
|
23
|
-
instructions: fields.instructions,
|
|
24
|
-
recurrence: fields.recurrence,
|
|
25
|
-
timezone: fields.timezone,
|
|
26
|
-
enabled: fields.enabled ?? true,
|
|
27
|
-
modelProvider: fields.modelProvider ?? void 0,
|
|
28
|
-
modelName: fields.modelName ?? void 0
|
|
29
|
-
});
|
|
30
|
-
job.setCreatedBy(currentUser);
|
|
31
|
-
job.setOwner(currentUser);
|
|
32
|
-
job.scheduleNextRun();
|
|
33
|
-
if (job.enabled && !job.nextRunAt) throw new Error("The date of the recurrence has already passed");
|
|
34
|
-
await this.agenticJobRepository?.create(job);
|
|
35
|
-
return { data: job.toJSON() };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
CreateAgenticJobUseCase = __decorateClass([
|
|
39
|
-
autoInjectable(),
|
|
40
|
-
__decorateParam(0, inject(AgenticJobRepository))
|
|
41
|
-
], CreateAgenticJobUseCase);
|
|
42
|
-
export {
|
|
43
|
-
CreateAgenticJobUseCase
|
|
44
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJob } from "../entities";
|
|
8
|
-
import { AgenticJobRepository } from "../repositories";
|
|
9
|
-
let DeleteAgenticJobUseCase = class extends BaseUseCase {
|
|
10
|
-
constructor(agenticJobRepository) {
|
|
11
|
-
super();
|
|
12
|
-
this.agenticJobRepository = agenticJobRepository;
|
|
13
|
-
}
|
|
14
|
-
agenticJobRepository;
|
|
15
|
-
async execute(params) {
|
|
16
|
-
const { id, hardDelete, currentUser } = params;
|
|
17
|
-
if (!id) throw new Error("Missing id");
|
|
18
|
-
if (hardDelete) {
|
|
19
|
-
if (!currentUser?.isAdmin()) this.throwError403();
|
|
20
|
-
const result2 = await this.agenticJobRepository?.deleteById(id);
|
|
21
|
-
return { data: { deletedCount: result2 } };
|
|
22
|
-
}
|
|
23
|
-
const job = AgenticJob.fromJSON({ _id: id });
|
|
24
|
-
job.setDeletedBy(currentUser);
|
|
25
|
-
job.unset(["nextRunAt"]);
|
|
26
|
-
const result = await this.agenticJobRepository?.update(job);
|
|
27
|
-
return { data: result };
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
DeleteAgenticJobUseCase = __decorateClass([
|
|
31
|
-
autoInjectable(),
|
|
32
|
-
__decorateParam(0, inject(AgenticJobRepository))
|
|
33
|
-
], DeleteAgenticJobUseCase);
|
|
34
|
-
export {
|
|
35
|
-
DeleteAgenticJobUseCase
|
|
36
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJobRun } from "../entities";
|
|
8
|
-
import { AgenticJobRepository, AgenticJobRunRepository } from "../repositories";
|
|
9
|
-
let FinishAgenticJobRunUseCase = class extends BaseUseCase {
|
|
10
|
-
constructor(agenticJobRepository, agenticJobRunRepository) {
|
|
11
|
-
super();
|
|
12
|
-
this.agenticJobRepository = agenticJobRepository;
|
|
13
|
-
this.agenticJobRunRepository = agenticJobRunRepository;
|
|
14
|
-
}
|
|
15
|
-
agenticJobRepository;
|
|
16
|
-
agenticJobRunRepository;
|
|
17
|
-
async execute(params) {
|
|
18
|
-
const { runId, workerId, status, error } = params;
|
|
19
|
-
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
20
|
-
const run = await this.agenticJobRunRepository.findById(runId);
|
|
21
|
-
if (!run) return { data: null };
|
|
22
|
-
const finished = AgenticJobRun.fromJSON({
|
|
23
|
-
...run,
|
|
24
|
-
status,
|
|
25
|
-
...status === "paused" ? {} : { finishedAt: now },
|
|
26
|
-
...error ? { error } : {}
|
|
27
|
-
});
|
|
28
|
-
const saved = await this.agenticJobRunRepository.update(finished);
|
|
29
|
-
if (run.jobId) {
|
|
30
|
-
await this.agenticJobRepository.release(String(run.jobId), workerId, {
|
|
31
|
-
lastRunAt: now,
|
|
32
|
-
lastRunStatus: status,
|
|
33
|
-
...status === "paused" ? { activeRunId: run._id } : {}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return { data: saved ?? finished.toJSON() };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
FinishAgenticJobRunUseCase = __decorateClass([
|
|
40
|
-
autoInjectable(),
|
|
41
|
-
__decorateParam(0, inject(AgenticJobRepository)),
|
|
42
|
-
__decorateParam(1, inject(AgenticJobRunRepository))
|
|
43
|
-
], FinishAgenticJobRunUseCase);
|
|
44
|
-
export {
|
|
45
|
-
FinishAgenticJobRunUseCase
|
|
46
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJobRepository } from "../repositories";
|
|
8
|
-
let GetAgenticJobByIdUseCase = class extends BaseUseCase {
|
|
9
|
-
constructor(agenticJobRepository) {
|
|
10
|
-
super();
|
|
11
|
-
this.agenticJobRepository = agenticJobRepository;
|
|
12
|
-
}
|
|
13
|
-
agenticJobRepository;
|
|
14
|
-
async execute(params) {
|
|
15
|
-
const { id } = params;
|
|
16
|
-
const result = await this.agenticJobRepository?.findById(id);
|
|
17
|
-
return { data: result ?? null };
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
GetAgenticJobByIdUseCase = __decorateClass([
|
|
21
|
-
autoInjectable(),
|
|
22
|
-
__decorateParam(0, inject(AgenticJobRepository))
|
|
23
|
-
], GetAgenticJobByIdUseCase);
|
|
24
|
-
export {
|
|
25
|
-
GetAgenticJobByIdUseCase
|
|
26
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import { AgenticJobRunRepository } from "../repositories";
|
|
8
|
-
let ListAgenticJobRunsByJobUseCase = class extends BaseUseCase {
|
|
9
|
-
constructor(agenticJobRunRepository) {
|
|
10
|
-
super();
|
|
11
|
-
this.agenticJobRunRepository = agenticJobRunRepository;
|
|
12
|
-
}
|
|
13
|
-
agenticJobRunRepository;
|
|
14
|
-
async execute(params) {
|
|
15
|
-
const { jobId, options } = params;
|
|
16
|
-
if (!jobId) throw new Error("Missing jobId");
|
|
17
|
-
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
-
const results = await this.agenticJobRunRepository?.findByJob(jobId, { page, limit, sortBy });
|
|
19
|
-
return { data: results ?? [] };
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
ListAgenticJobRunsByJobUseCase = __decorateClass([
|
|
23
|
-
autoInjectable(),
|
|
24
|
-
__decorateParam(0, inject(AgenticJobRunRepository))
|
|
25
|
-
], ListAgenticJobRunsByJobUseCase);
|
|
26
|
-
export {
|
|
27
|
-
ListAgenticJobRunsByJobUseCase
|
|
28
|
-
};
|