openloops 0.6.0 → 0.7.2
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/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/dist/clients/llm/llm-client.mjs +0 -1
- package/dist/clients/llm/llm-error.mjs +0 -1
- package/dist/clients/llm/llm-types.mjs +0 -1
- package/dist/clients/llm/model-resolution.mjs +0 -1
- package/dist/clients/llm/pi-ai-adapter.mjs +0 -1
- package/dist/clients/llm/sampling-rules.mjs +0 -1
- package/dist/clients/serper/serper-client.mjs +0 -1
- package/dist/clients/slack/slack-client.mjs +0 -1
- package/dist/common/base/base.app.d.ts +3 -3
- package/dist/common/base/base.app.mjs +0 -1
- package/dist/common/base/base.entity.d.ts +4 -16
- package/dist/common/base/base.entity.js +11 -39
- package/dist/common/base/base.entity.mjs +11 -40
- package/dist/common/base/base.use-case.d.ts +1 -7
- package/dist/common/base/base.use-case.mjs +0 -1
- package/dist/common/base/current-session.mjs +0 -1
- package/dist/common/base/current-user.mjs +0 -1
- package/dist/common/base/share.mjs +0 -1
- package/dist/common/base/utils/index.d.ts +1 -2
- package/dist/common/base/utils/index.js +2 -4
- package/dist/common/base/utils/index.mjs +1 -2
- package/dist/common/base/utils/is-plain-object.mjs +0 -1
- package/dist/common/base/utils/to-patch.d.ts +9 -0
- package/dist/common/base/utils/to-patch.js +46 -0
- package/dist/common/base/utils/to-patch.mjs +21 -0
- package/dist/common/constants/harness.mjs +0 -1
- package/dist/common/error/http-error.mjs +0 -1
- package/dist/common/error/reportError.mjs +0 -1
- package/dist/common/error/sentry-client.mjs +0 -1
- package/dist/common/helpers/escape-regex.mjs +0 -1
- package/dist/common/helpers/extract-json-from-text.mjs +0 -1
- package/dist/common/helpers/sanitize-string.mjs +0 -1
- package/dist/common/logger/pino.mjs +0 -1
- package/dist/common/repositories/mongo-db.client.mjs +0 -1
- package/dist/common/repositories/mongo-db.repository.d.ts +15 -4
- package/dist/common/repositories/mongo-db.repository.js +44 -15
- package/dist/common/repositories/mongo-db.repository.mjs +44 -16
- package/dist/common/repositories/scope.mjs +0 -1
- package/dist/common/utils/database-name.mjs +0 -1
- package/dist/common/utils/number-setting.mjs +0 -1
- package/dist/common/utils/secret-manager.mjs +0 -1
- package/dist/db/indexes/agent-actions.mjs +0 -1
- package/dist/db/indexes/agent-tasks.mjs +0 -1
- package/dist/db/indexes/agent-traces.mjs +0 -1
- package/dist/db/indexes/automation-runs.mjs +0 -1
- package/dist/db/indexes/automations.mjs +0 -1
- package/dist/db/indexes/chats.mjs +0 -1
- package/dist/db/indexes/index.js +3 -1
- package/dist/db/indexes/index.mjs +3 -2
- package/dist/db/indexes/llm-calls.mjs +0 -1
- package/dist/db/indexes/mcp-servers.js +2 -1
- package/dist/db/indexes/mcp-servers.mjs +2 -2
- package/dist/db/indexes/refresh-tokens.d.ts +2 -0
- package/dist/{common/decorators/mask-in-logs/index.js → db/indexes/refresh-tokens.js} +16 -5
- package/dist/db/indexes/refresh-tokens.mjs +9 -0
- package/dist/db/indexes/revoked-tokens.mjs +0 -1
- package/dist/db/indexes/workspace-items.mjs +0 -1
- package/dist/db/migrations/automations.mjs +0 -1
- package/dist/guardrails/guard.mjs +0 -1
- package/dist/guardrails/index.mjs +0 -1
- package/dist/guardrails/input/block-card.mjs +0 -1
- package/dist/guardrails/input/block-code.mjs +0 -1
- package/dist/guardrails/input/block-email.mjs +0 -1
- package/dist/guardrails/input/create-block-input-oversize.mjs +0 -1
- package/dist/guardrails/input/diagnostic-sanity.mjs +0 -1
- package/dist/guardrails/input/input-check.mjs +0 -1
- package/dist/harness/agent-loop.mjs +0 -1
- package/dist/harness/agent-state.mjs +0 -1
- package/dist/harness/agent.d.ts +1 -3
- package/dist/harness/agent.js +29 -23
- package/dist/harness/agent.mjs +29 -24
- package/dist/harness/native-tools.mjs +0 -1
- package/dist/harness/skills/approval-request.mjs +0 -1
- package/dist/harness/skills/autonomous-answer.mjs +0 -1
- package/dist/harness/skills/confirmation-gate.mjs +0 -1
- package/dist/harness/skills/mcp-change-review.mjs +0 -1
- package/dist/harness/tool-catalog.mjs +0 -1
- package/dist/harness/tool-pipeline.mjs +0 -1
- package/dist/harness/utils/activity.mjs +0 -1
- package/dist/harness/utils/describe-shape.mjs +0 -1
- package/dist/harness/utils/grounding.mjs +0 -1
- package/dist/harness/utils/rank-tools-by-keywords.mjs +0 -1
- package/dist/harness/workspace.js +7 -7
- package/dist/harness/workspace.mjs +7 -8
- package/dist/loops/agi/loop.mjs +0 -1
- package/dist/loops/agi/skills/reasoning-engine.mjs +0 -1
- package/dist/loops/shared/skills/fast-responder.mjs +0 -1
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +3 -1
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/refresh-token.entity.d.ts +25 -0
- package/dist/services/authentication/entities/refresh-token.entity.js +75 -0
- package/dist/services/authentication/entities/refresh-token.entity.mjs +51 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -1
- package/dist/services/authentication/helpers/auth-config.d.ts +9 -0
- package/dist/services/authentication/helpers/auth-config.js +36 -0
- package/dist/services/authentication/helpers/auth-config.mjs +12 -0
- package/dist/services/authentication/helpers/session-tokens.d.ts +16 -0
- package/dist/services/authentication/helpers/session-tokens.js +60 -0
- package/dist/services/authentication/helpers/session-tokens.mjs +35 -0
- package/dist/services/authentication/helpers/tokens.d.ts +43 -0
- package/dist/services/authentication/helpers/tokens.js +113 -0
- package/dist/services/authentication/helpers/tokens.mjs +71 -0
- package/dist/services/authentication/index.d.ts +3 -0
- package/dist/services/authentication/index.js +23 -0
- package/dist/services/authentication/index.mjs +11 -0
- package/dist/services/authentication/module.d.ts +12 -3
- package/dist/services/authentication/module.js +40 -7
- package/dist/services/authentication/module.mjs +34 -7
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/authentication/repositories/index.js +3 -1
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/refresh-token.repository.d.ts +10 -0
- package/dist/services/authentication/repositories/refresh-token.repository.js +60 -0
- package/dist/services/authentication/repositories/refresh-token.repository.mjs +36 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +3 -15
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +3 -10
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +12 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +40 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +43 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +19 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +40 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +6 -8
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +4 -18
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +4 -13
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +18 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +49 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +25 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.js +48 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/login.use-case.d.ts +11 -11
- package/dist/services/authentication/use-cases/login.use-case.js +18 -54
- package/dist/services/authentication/use-cases/login.use-case.mjs +17 -38
- package/dist/services/authentication/use-cases/logout.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/logout.use-case.js +48 -0
- package/dist/services/authentication/use-cases/logout.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/refresh.use-case.d.ts +23 -0
- package/dist/services/authentication/use-cases/refresh.use-case.js +84 -0
- package/dist/services/authentication/use-cases/refresh.use-case.mjs +60 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.js +61 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.mjs +37 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +4 -6
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +12 -26
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +10 -19
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +16 -0
- package/dist/services/automations/entities/automation-run.entity.mjs +0 -1
- package/dist/services/automations/entities/automation.entity.d.ts +1 -0
- package/dist/services/automations/entities/automation.entity.js +2 -1
- package/dist/services/automations/entities/automation.entity.mjs +2 -2
- package/dist/services/automations/entities/recurrence.mjs +0 -1
- package/dist/services/automations/entities/trigger.mjs +0 -1
- package/dist/services/automations/module.d.ts +0 -1
- package/dist/services/automations/module.js +20 -22
- package/dist/services/automations/module.mjs +20 -23
- package/dist/services/automations/repositories/automation-run.repository.js +7 -22
- package/dist/services/automations/repositories/automation-run.repository.mjs +7 -17
- package/dist/services/automations/repositories/automation.repository.js +25 -39
- package/dist/services/automations/repositories/automation.repository.mjs +25 -34
- package/dist/services/automations/runner/automation-runner.js +9 -12
- package/dist/services/automations/runner/automation-runner.mjs +9 -13
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +5 -19
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-due-automations.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/create-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -22
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/finish-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +5 -19
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +7 -9
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +6 -20
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +6 -15
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +3 -15
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +3 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +8 -23
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +8 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +4 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +4 -13
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +8 -21
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +9 -17
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +8 -22
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +12 -27
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +12 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +7 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +7 -17
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/update-automation.use-case.js +10 -24
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +10 -19
- package/dist/services/automations/utils/automation-event-error.mjs +0 -1
- package/dist/services/automations/utils/automation-fields.mjs +0 -1
- package/dist/services/automations/utils/event-message.mjs +0 -1
- package/dist/services/automations/utils/event-token.d.ts +1 -2
- package/dist/services/automations/utils/event-token.js +9 -35
- package/dist/services/automations/utils/event-token.mjs +9 -25
- package/dist/services/automations/utils/next-run.mjs +0 -1
- package/dist/services/automations/utils/open-run.mjs +0 -1
- package/dist/services/automations/utils/previous-run.js +1 -1
- package/dist/services/automations/utils/previous-run.mjs +1 -2
- package/dist/services/automations/utils/runner-scope.mjs +0 -1
- package/dist/services/automations/utils/settings.mjs +0 -1
- package/dist/services/chats/entities/chat-message.entity.mjs +0 -1
- package/dist/services/chats/entities/chat-settings.entity.mjs +0 -1
- package/dist/services/chats/entities/chat.entity.d.ts +1 -0
- package/dist/services/chats/entities/chat.entity.js +3 -2
- package/dist/services/chats/entities/chat.entity.mjs +3 -3
- package/dist/services/chats/module.d.ts +0 -1
- package/dist/services/chats/module.js +5 -7
- package/dist/services/chats/module.mjs +5 -8
- package/dist/services/chats/repositories/chat.repository.js +5 -20
- package/dist/services/chats/repositories/chat.repository.mjs +5 -15
- package/dist/services/chats/use-cases/create-chat.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/create-chat.use-case.js +5 -19
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -22
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +8 -17
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +6 -20
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/interrupt-execution.use-case.js +6 -20
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/update-chat.use-case.d.ts +5 -6
- package/dist/services/chats/use-cases/update-chat.use-case.js +8 -26
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +8 -21
- package/dist/services/chats/utils/deprecated-activity.mjs +0 -1
- package/dist/services/llmcalls/entities/llmcall.entity.mjs +0 -1
- package/dist/services/llmcalls/module.d.ts +0 -1
- package/dist/services/llmcalls/module.js +4 -6
- package/dist/services/llmcalls/module.mjs +4 -7
- package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -20
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +5 -15
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -22
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +8 -17
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +6 -20
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +6 -15
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -21
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +7 -16
- package/dist/services/llmcalls/utils/usage-periods.mjs +0 -1
- package/dist/services/llmcalls/utils/usage-totals.mjs +0 -1
- package/dist/services/mcp-servers/admin/index.d.ts +1 -0
- package/dist/{common/decorators → services/mcp-servers/admin}/index.js +4 -4
- package/dist/services/mcp-servers/admin/index.mjs +1 -0
- package/dist/services/mcp-servers/admin/module.d.ts +10 -0
- package/dist/services/mcp-servers/admin/module.js +55 -0
- package/dist/services/mcp-servers/admin/module.mjs +27 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +50 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +26 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +44 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +20 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +41 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +17 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +16 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +42 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +18 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +59 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +35 -0
- package/dist/services/mcp-servers/entities/mcp-manifest.mjs +0 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +10 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.js +28 -3
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +28 -4
- package/dist/services/mcp-servers/internal.d.ts +7 -0
- package/dist/{common/base/utils/flatten-object.js → services/mcp-servers/internal.js} +9 -22
- package/dist/services/mcp-servers/internal.mjs +8 -0
- package/dist/services/mcp-servers/module.d.ts +0 -1
- package/dist/services/mcp-servers/module.js +8 -10
- package/dist/services/mcp-servers/module.mjs +8 -11
- package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +8 -0
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +28 -24
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +29 -20
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +5 -21
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -16
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -21
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +7 -16
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -22
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +8 -17
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +7 -19
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +7 -14
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +10 -26
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +10 -21
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -23
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +9 -18
- package/dist/services/tasks/entities/agent-action.entity.mjs +0 -1
- package/dist/services/tasks/entities/agent-task.entity.mjs +0 -1
- package/dist/services/tasks/module.d.ts +0 -1
- package/dist/services/tasks/module.js +7 -9
- package/dist/services/tasks/module.mjs +7 -10
- package/dist/services/tasks/repositories/agent-action.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-action.repository.mjs +5 -16
- package/dist/services/tasks/repositories/agent-task.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-task.repository.mjs +5 -16
- package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-action.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +5 -19
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-action.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +6 -15
- package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-task.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +6 -15
- package/dist/services/traces/entities/agent-trace-entry.entity.mjs +0 -1
- package/dist/services/traces/module.d.ts +0 -1
- package/dist/services/traces/module.js +2 -4
- package/dist/services/traces/module.mjs +2 -5
- package/dist/services/traces/repositories/agent-trace.repository.js +3 -15
- package/dist/services/traces/repositories/agent-trace.repository.mjs +3 -10
- package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +6 -8
- package/dist/services/traces/use-cases/create-agent-traces.use-case.js +5 -19
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +5 -14
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +6 -6
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +5 -19
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +5 -14
- package/dist/services/users/entities/user-acquisition.js +2 -2
- package/dist/services/users/entities/user-acquisition.mjs +2 -3
- package/dist/services/users/entities/user-country.js +2 -2
- package/dist/services/users/entities/user-country.mjs +2 -3
- package/dist/services/users/entities/user-currency.js +2 -2
- package/dist/services/users/entities/user-currency.mjs +2 -3
- package/dist/services/users/entities/user-default-model.js +2 -2
- package/dist/services/users/entities/user-default-model.mjs +2 -3
- package/dist/services/users/entities/user-email.value-object.mjs +0 -1
- package/dist/services/users/entities/user-language.js +2 -2
- package/dist/services/users/entities/user-language.mjs +2 -3
- package/dist/services/users/entities/user-marketing.js +2 -2
- package/dist/services/users/entities/user-marketing.mjs +2 -3
- package/dist/services/users/entities/user-notification-preferences.mjs +0 -1
- package/dist/services/users/entities/user-password.value-object.mjs +0 -1
- package/dist/services/users/entities/user-permissions.mjs +0 -1
- package/dist/services/users/entities/user-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-schedule.mjs +0 -1
- package/dist/services/users/entities/user-timezone.js +2 -2
- package/dist/services/users/entities/user-timezone.mjs +2 -3
- package/dist/services/users/entities/user.entity.d.ts +1 -0
- package/dist/services/users/entities/user.entity.js +9 -22
- package/dist/services/users/entities/user.entity.mjs +9 -17
- package/dist/services/users/module.d.ts +2 -1
- package/dist/services/users/module.js +12 -7
- package/dist/services/users/module.mjs +11 -8
- package/dist/services/users/repositories/user.repository.d.ts +2 -0
- package/dist/services/users/repositories/user.repository.js +11 -20
- package/dist/services/users/repositories/user.repository.mjs +11 -15
- package/dist/services/users/use-cases/change-password.use-case.d.ts +15 -0
- package/dist/services/users/use-cases/change-password.use-case.js +52 -0
- package/dist/services/users/use-cases/change-password.use-case.mjs +28 -0
- package/dist/services/users/use-cases/create-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/create-user.use-case.js +5 -19
- package/dist/services/users/use-cases/create-user.use-case.mjs +5 -14
- package/dist/services/users/use-cases/delete-user.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/delete-user.use-case.js +8 -22
- package/dist/services/users/use-cases/delete-user.use-case.mjs +8 -17
- package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/get-user-by-id.use-case.js +6 -20
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +6 -15
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +5 -19
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +5 -14
- package/dist/services/users/use-cases/update-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/update-user.use-case.js +9 -22
- package/dist/services/users/use-cases/update-user.use-case.mjs +9 -17
- package/dist/services/users/utils/default-model.mjs +0 -1
- package/dist/services/workspaces/entities/workspace-item.entity.mjs +0 -1
- package/dist/services/workspaces/module.d.ts +0 -1
- package/dist/services/workspaces/module.js +5 -7
- package/dist/services/workspaces/module.mjs +5 -8
- package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -20
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +5 -15
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +6 -8
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +7 -21
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +7 -16
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +6 -20
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -15
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +5 -14
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -24
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +10 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +5 -14
- package/dist/skills/call-modes.mjs +0 -1
- package/dist/skills/runtime-context.mjs +0 -1
- package/dist/skills/shared/shared-rules.mjs +0 -1
- package/dist/skills/skill.js +1 -2
- package/dist/skills/skill.mjs +1 -3
- package/dist/tools/core/call-ai/call-ai.skill.mjs +0 -1
- package/dist/tools/core/call-ai/call-ai.tool.mjs +0 -1
- package/dist/tools/core/slack/send-slack-message.tool.mjs +0 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +0 -1
- package/dist/tools/tool.mjs +0 -1
- package/docs/agent.md +1 -1
- package/docs/authentication.md +95 -16
- package/docs/authorization.md +1 -1
- package/docs/automations.md +29 -11
- package/docs/chats.md +1 -1
- package/docs/configuration.md +1 -2
- package/docs/integration-guide.md +2 -2
- package/docs/mcp-servers.md +85 -2
- package/docs/usage.md +5 -5
- package/docs/users.md +1 -1
- package/examples/authentication/login.ts +1 -1
- package/examples/automations/create-automation.ts +1 -1
- package/examples/automations/create-event-automation.ts +2 -2
- package/examples/automations/list-automation-runs.ts +2 -2
- package/examples/automations/list-automations.ts +1 -1
- package/examples/automations/preview-automation-runs.ts +1 -1
- package/examples/automations/receive-automation-event.ts +1 -1
- package/examples/automations/revoke-automation-event-token.ts +2 -2
- package/examples/automations/run-automation-worker.ts +8 -0
- package/examples/automations/update-automation.ts +2 -2
- package/examples/chats/get-chat-by-id.ts +2 -2
- package/examples/chats/list-autonomous-chats.ts +1 -1
- package/examples/chats/list-chats.ts +1 -1
- package/examples/mcps/create-mcp.ts +1 -0
- package/examples/mcps/decide-mcp.ts +3 -3
- package/examples/mcps/internal-mcp-admin.ts +43 -0
- package/examples/mcps/internal-mcp.ts +14 -3
- package/examples/mcps/list-all-mcps.ts +1 -1
- package/examples/mcps/update-mcp.ts +1 -1
- package/examples/mcps/verify-mcp.ts +1 -1
- package/examples/usage/get-chat-usage.ts +2 -2
- package/examples/usage/get-message-usage.ts +2 -2
- package/examples/usage/get-usage-stats-by-range.ts +1 -1
- package/examples/usage/get-usage-stats.ts +3 -3
- package/examples/users/set-default-model.ts +1 -1
- package/package.json +6 -4
- package/dist/chunk-CF3WOMB3.mjs +0 -16
- package/dist/common/base/utils/delete-empty-fields.d.ts +0 -1
- package/dist/common/base/utils/delete-empty-fields.js +0 -66
- package/dist/common/base/utils/delete-empty-fields.mjs +0 -43
- package/dist/common/base/utils/flatten-object.d.ts +0 -1
- package/dist/common/base/utils/flatten-object.mjs +0 -22
- package/dist/common/decorators/index.d.ts +0 -1
- package/dist/common/decorators/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
- package/dist/common/decorators/mask-in-logs/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +0 -2
- package/dist/common/decorators/mask-in-logs/mask-in-logs.js +0 -53
- package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +0 -29
|
@@ -25,7 +25,6 @@ module.exports = __toCommonJS(automation_runner_exports);
|
|
|
25
25
|
var import_node_crypto = require("node:crypto");
|
|
26
26
|
var import_node_os = require("node:os");
|
|
27
27
|
var import_logger = require("../../../common/logger/index.js");
|
|
28
|
-
var import_secret_manager = require("../../../common/utils/secret-manager.js");
|
|
29
28
|
var import_base = require("../../../common/base/index.js");
|
|
30
29
|
var import_agent = require("../../../harness/agent.js");
|
|
31
30
|
var import_loop = require("../../../loops/agi/loop.js");
|
|
@@ -40,7 +39,6 @@ var import_finish_automation_run = require("../use-cases/finish-automation-run.u
|
|
|
40
39
|
var import_attach_automation_run_chat = require("../use-cases/attach-automation-run-chat.use-case");
|
|
41
40
|
var import_renew_automation_lease = require("../use-cases/renew-automation-lease.use-case");
|
|
42
41
|
var import_sync_automation_runs = require("../use-cases/sync-automation-runs.use-case");
|
|
43
|
-
var import_tsyringe = require("tsyringe");
|
|
44
42
|
const DEFAULT_MAX_CONCURRENT_RUNS = 3;
|
|
45
43
|
const DEFAULT_STOP_TIMEOUT_MS = 3e4;
|
|
46
44
|
const PAUSED_STATUSES = ["awaiting_user_confirmation", "awaiting_user_input"];
|
|
@@ -82,22 +80,22 @@ class AutomationRunner {
|
|
|
82
80
|
async tick() {
|
|
83
81
|
const capacity = (this.options.maxConcurrentRuns ?? DEFAULT_MAX_CONCURRENT_RUNS) - this.inFlight.size;
|
|
84
82
|
try {
|
|
85
|
-
await
|
|
83
|
+
await new import_sync_automation_runs.SyncAutomationRunsUseCase().execute({});
|
|
86
84
|
} catch (error) {
|
|
87
85
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] Failed to sync the open runs");
|
|
88
86
|
}
|
|
89
87
|
if (capacity <= 0) return;
|
|
90
|
-
const
|
|
88
|
+
const data = await new import_claim_due_automations.ClaimDueAutomationsUseCase().execute({ workerId: this.workerId, limit: capacity, leaseMs: this.options.leaseMs ?? (0, import_settings.leaseMs)() });
|
|
91
89
|
for (const { automation, run } of data.skipped) await this.notify({ automation, run });
|
|
92
90
|
for (const { automation, run } of data.claimed) this.track(this.execute(automation, run));
|
|
93
91
|
const remaining = capacity - data.claimed.length;
|
|
94
92
|
if (remaining <= 0) return;
|
|
95
|
-
const
|
|
93
|
+
const queued = await new import_claim_queued_automation_runs.ClaimQueuedAutomationRunsUseCase().execute({ workerId: this.workerId, limit: remaining, leaseMs: this.options.leaseMs ?? (0, import_settings.leaseMs)() });
|
|
96
94
|
for (const { automation, run } of queued.skipped) await this.notify({ automation, run });
|
|
97
95
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
98
96
|
}
|
|
99
97
|
async runNow(params) {
|
|
100
|
-
const
|
|
98
|
+
const data = await new import_start_automation_run.StartAutomationRunUseCase().execute({ automationId: params.automationId, currentUser: params.currentUser, scope: params.scope, workerId: this.workerId, leaseMs: this.options.leaseMs ?? (0, import_settings.leaseMs)() });
|
|
101
99
|
this.track(this.execute(data.automation, data.run));
|
|
102
100
|
return { run: data.run };
|
|
103
101
|
}
|
|
@@ -123,7 +121,7 @@ class AutomationRunner {
|
|
|
123
121
|
const automationId = String(automation._id);
|
|
124
122
|
const runId = String(run._id);
|
|
125
123
|
const heartbeat = setInterval(() => {
|
|
126
|
-
|
|
124
|
+
new import_renew_automation_lease.RenewAutomationLeaseUseCase().execute({ automationId, workerId: this.workerId, leaseMs }).catch((error2) => {
|
|
127
125
|
this.logger.error({ error: error2?.message ?? error2, automationId }, "[AUTOMATIONS] Failed to renew the lease of an automation");
|
|
128
126
|
});
|
|
129
127
|
}, Math.max(Math.floor(leaseMs / 3), 1e3));
|
|
@@ -141,7 +139,7 @@ class AutomationRunner {
|
|
|
141
139
|
} finally {
|
|
142
140
|
clearInterval(heartbeat);
|
|
143
141
|
}
|
|
144
|
-
const
|
|
142
|
+
const data = await new import_finish_automation_run.FinishAutomationRunUseCase().execute({ runId, workerId: this.workerId, status, error });
|
|
145
143
|
await this.notify({ automation, run: data ?? run, chat });
|
|
146
144
|
}
|
|
147
145
|
async runAgent(automation, run) {
|
|
@@ -155,15 +153,14 @@ class AutomationRunner {
|
|
|
155
153
|
draft.settings?.setExecutionMode("autonomous");
|
|
156
154
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
157
155
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
158
|
-
const
|
|
156
|
+
const created = await (0, import_chats.createChat)({ payload: draft.toJSON(), currentUser });
|
|
159
157
|
const chatId = String(created?._id);
|
|
160
|
-
await
|
|
158
|
+
await new import_attach_automation_run_chat.AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
161
159
|
const result = await agent.run({
|
|
162
160
|
input: { message: (0, import_event_message.buildMessage)(automation.instructions, run.payload), chatId },
|
|
163
161
|
options: { executionMode: "autonomous", ...model },
|
|
164
162
|
currentUser,
|
|
165
|
-
currentSession: import_base.CurrentSession.fromJSON({ location: { timezone: currentUser.preferences?.timezone?.ianaIdentifier } })
|
|
166
|
-
serviceToken: process.env.INTERNAL_MCP_TOKEN ? import_secret_manager.secretManager.get("INTERNAL_MCP_TOKEN") : void 0
|
|
163
|
+
currentSession: import_base.CurrentSession.fromJSON({ location: { timezone: currentUser.preferences?.timezone?.ianaIdentifier } })
|
|
167
164
|
});
|
|
168
165
|
const chat = result.data;
|
|
169
166
|
const state = chat?.state;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "../../../chunk-CF3WOMB3.mjs";
|
|
2
1
|
import { randomBytes } from "node:crypto";
|
|
3
2
|
import { hostname } from "node:os";
|
|
4
3
|
import { Logger } from "../../../common/logger/index.js";
|
|
5
|
-
import { secretManager } from "../../../common/utils/secret-manager.js";
|
|
6
4
|
import { CurrentUser, CurrentSession } from "../../../common/base/index.js";
|
|
7
5
|
import { Agent } from "../../../harness/agent.js";
|
|
8
6
|
import { AgiLoop } from "../../../loops/agi/loop.js";
|
|
@@ -17,7 +15,6 @@ import { FinishAutomationRunUseCase } from "../use-cases/finish-automation-run.u
|
|
|
17
15
|
import { AttachAutomationRunChatUseCase } from "../use-cases/attach-automation-run-chat.use-case";
|
|
18
16
|
import { RenewAutomationLeaseUseCase } from "../use-cases/renew-automation-lease.use-case";
|
|
19
17
|
import { SyncAutomationRunsUseCase } from "../use-cases/sync-automation-runs.use-case";
|
|
20
|
-
import { container } from "tsyringe";
|
|
21
18
|
const DEFAULT_MAX_CONCURRENT_RUNS = 3;
|
|
22
19
|
const DEFAULT_STOP_TIMEOUT_MS = 3e4;
|
|
23
20
|
const PAUSED_STATUSES = ["awaiting_user_confirmation", "awaiting_user_input"];
|
|
@@ -59,22 +56,22 @@ class AutomationRunner {
|
|
|
59
56
|
async tick() {
|
|
60
57
|
const capacity = (this.options.maxConcurrentRuns ?? DEFAULT_MAX_CONCURRENT_RUNS) - this.inFlight.size;
|
|
61
58
|
try {
|
|
62
|
-
await
|
|
59
|
+
await new SyncAutomationRunsUseCase().execute({});
|
|
63
60
|
} catch (error) {
|
|
64
61
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] Failed to sync the open runs");
|
|
65
62
|
}
|
|
66
63
|
if (capacity <= 0) return;
|
|
67
|
-
const
|
|
64
|
+
const data = await new ClaimDueAutomationsUseCase().execute({ workerId: this.workerId, limit: capacity, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
68
65
|
for (const { automation, run } of data.skipped) await this.notify({ automation, run });
|
|
69
66
|
for (const { automation, run } of data.claimed) this.track(this.execute(automation, run));
|
|
70
67
|
const remaining = capacity - data.claimed.length;
|
|
71
68
|
if (remaining <= 0) return;
|
|
72
|
-
const
|
|
69
|
+
const queued = await new ClaimQueuedAutomationRunsUseCase().execute({ workerId: this.workerId, limit: remaining, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
73
70
|
for (const { automation, run } of queued.skipped) await this.notify({ automation, run });
|
|
74
71
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
75
72
|
}
|
|
76
73
|
async runNow(params) {
|
|
77
|
-
const
|
|
74
|
+
const data = await new StartAutomationRunUseCase().execute({ automationId: params.automationId, currentUser: params.currentUser, scope: params.scope, workerId: this.workerId, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
78
75
|
this.track(this.execute(data.automation, data.run));
|
|
79
76
|
return { run: data.run };
|
|
80
77
|
}
|
|
@@ -100,7 +97,7 @@ class AutomationRunner {
|
|
|
100
97
|
const automationId = String(automation._id);
|
|
101
98
|
const runId = String(run._id);
|
|
102
99
|
const heartbeat = setInterval(() => {
|
|
103
|
-
|
|
100
|
+
new RenewAutomationLeaseUseCase().execute({ automationId, workerId: this.workerId, leaseMs }).catch((error2) => {
|
|
104
101
|
this.logger.error({ error: error2?.message ?? error2, automationId }, "[AUTOMATIONS] Failed to renew the lease of an automation");
|
|
105
102
|
});
|
|
106
103
|
}, Math.max(Math.floor(leaseMs / 3), 1e3));
|
|
@@ -118,7 +115,7 @@ class AutomationRunner {
|
|
|
118
115
|
} finally {
|
|
119
116
|
clearInterval(heartbeat);
|
|
120
117
|
}
|
|
121
|
-
const
|
|
118
|
+
const data = await new FinishAutomationRunUseCase().execute({ runId, workerId: this.workerId, status, error });
|
|
122
119
|
await this.notify({ automation, run: data ?? run, chat });
|
|
123
120
|
}
|
|
124
121
|
async runAgent(automation, run) {
|
|
@@ -132,15 +129,14 @@ class AutomationRunner {
|
|
|
132
129
|
draft.settings?.setExecutionMode("autonomous");
|
|
133
130
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
134
131
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
135
|
-
const
|
|
132
|
+
const created = await createChat({ payload: draft.toJSON(), currentUser });
|
|
136
133
|
const chatId = String(created?._id);
|
|
137
|
-
await
|
|
134
|
+
await new AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
138
135
|
const result = await agent.run({
|
|
139
136
|
input: { message: buildMessage(automation.instructions, run.payload), chatId },
|
|
140
137
|
options: { executionMode: "autonomous", ...model },
|
|
141
138
|
currentUser,
|
|
142
|
-
currentSession: CurrentSession.fromJSON({ location: { timezone: currentUser.preferences?.timezone?.ianaIdentifier } })
|
|
143
|
-
serviceToken: process.env.INTERNAL_MCP_TOKEN ? secretManager.get("INTERNAL_MCP_TOKEN") : void 0
|
|
139
|
+
currentSession: CurrentSession.fromJSON({ location: { timezone: currentUser.preferences?.timezone?.ianaIdentifier } })
|
|
144
140
|
});
|
|
145
141
|
const chat = result.data;
|
|
146
142
|
const state = chat?.state;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
runId: string;
|
|
6
6
|
chatId: string;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
data: AutomationRunProps | null;
|
|
10
|
-
}
|
|
8
|
+
export type Output = AutomationRunProps | null;
|
|
11
9
|
export declare class AttachAutomationRunChatUseCase extends BaseUseCase<Params, Output> {
|
|
12
|
-
private readonly automationRunRepository
|
|
13
|
-
constructor(automationRunRepository?: AutomationRunRepository
|
|
10
|
+
private readonly automationRunRepository;
|
|
11
|
+
constructor(automationRunRepository?: AutomationRunRepository);
|
|
14
12
|
execute(params: Params): Promise<Output>;
|
|
15
13
|
}
|
|
@@ -16,27 +16,17 @@ 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 __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var attach_automation_run_chat_use_case_exports = {};
|
|
29
20
|
__export(attach_automation_run_chat_use_case_exports, {
|
|
30
21
|
AttachAutomationRunChatUseCase: () => AttachAutomationRunChatUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(attach_automation_run_chat_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_entities = require("../entities");
|
|
36
26
|
var import_repositories = require("../repositories");
|
|
37
27
|
var import_runner_scope = require("../utils/runner-scope");
|
|
38
|
-
|
|
39
|
-
constructor(automationRunRepository) {
|
|
28
|
+
class AttachAutomationRunChatUseCase extends import_base.BaseUseCase {
|
|
29
|
+
constructor(automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
40
30
|
super();
|
|
41
31
|
this.automationRunRepository = automationRunRepository;
|
|
42
32
|
}
|
|
@@ -44,15 +34,11 @@ let AttachAutomationRunChatUseCase = class extends import_base.BaseUseCase {
|
|
|
44
34
|
async execute(params) {
|
|
45
35
|
const { runId, chatId } = params;
|
|
46
36
|
const run = await this.automationRunRepository.findById(runId, import_runner_scope.runnerScope);
|
|
47
|
-
if (!run) return
|
|
37
|
+
if (!run) return null;
|
|
48
38
|
const saved = await this.automationRunRepository.update(import_entities.AutomationRun.fromJSON({ ...run, chatId }), import_runner_scope.runnerScope);
|
|
49
|
-
return
|
|
39
|
+
return saved;
|
|
50
40
|
}
|
|
51
|
-
}
|
|
52
|
-
AttachAutomationRunChatUseCase = __decorateClass([
|
|
53
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
54
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
55
|
-
], AttachAutomationRunChatUseCase);
|
|
41
|
+
}
|
|
56
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
43
|
0 && (module.exports = {
|
|
58
44
|
AttachAutomationRunChatUseCase
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { AutomationRun } from "../entities";
|
|
8
3
|
import { AutomationRunRepository } from "../repositories";
|
|
9
4
|
import { runnerScope } from "../utils/runner-scope";
|
|
10
|
-
|
|
11
|
-
constructor(automationRunRepository) {
|
|
5
|
+
class AttachAutomationRunChatUseCase extends BaseUseCase {
|
|
6
|
+
constructor(automationRunRepository = new AutomationRunRepository()) {
|
|
12
7
|
super();
|
|
13
8
|
this.automationRunRepository = automationRunRepository;
|
|
14
9
|
}
|
|
@@ -16,15 +11,11 @@ let AttachAutomationRunChatUseCase = class extends BaseUseCase {
|
|
|
16
11
|
async execute(params) {
|
|
17
12
|
const { runId, chatId } = params;
|
|
18
13
|
const run = await this.automationRunRepository.findById(runId, runnerScope);
|
|
19
|
-
if (!run) return
|
|
14
|
+
if (!run) return null;
|
|
20
15
|
const saved = await this.automationRunRepository.update(AutomationRun.fromJSON({ ...run, chatId }), runnerScope);
|
|
21
|
-
return
|
|
16
|
+
return saved;
|
|
22
17
|
}
|
|
23
|
-
}
|
|
24
|
-
AttachAutomationRunChatUseCase = __decorateClass([
|
|
25
|
-
autoInjectable(),
|
|
26
|
-
__decorateParam(0, inject(AutomationRunRepository))
|
|
27
|
-
], AttachAutomationRunChatUseCase);
|
|
18
|
+
}
|
|
28
19
|
export {
|
|
29
20
|
AttachAutomationRunChatUseCase
|
|
30
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
@@ -12,17 +12,15 @@ export interface ClaimedRun {
|
|
|
12
12
|
automation: AutomationProps;
|
|
13
13
|
run: AutomationRunProps;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
}
|
|
15
|
+
export type Output = {
|
|
16
|
+
claimed: ClaimedRun[];
|
|
17
|
+
skipped: ClaimedRun[];
|
|
18
|
+
};
|
|
21
19
|
export declare class ClaimDueAutomationsUseCase extends BaseUseCase<Params, Output> {
|
|
22
|
-
private readonly automationRepository
|
|
23
|
-
private readonly automationRunRepository
|
|
24
|
-
private readonly syncRun
|
|
20
|
+
private readonly automationRepository;
|
|
21
|
+
private readonly automationRunRepository;
|
|
22
|
+
private readonly syncRun;
|
|
25
23
|
private readonly log;
|
|
26
|
-
constructor(automationRepository?: AutomationRepository
|
|
24
|
+
constructor(automationRepository?: AutomationRepository, automationRunRepository?: AutomationRunRepository, syncRun?: SyncAutomationRunUseCase);
|
|
27
25
|
execute(params: Params): Promise<Output>;
|
|
28
26
|
}
|
|
@@ -16,21 +16,11 @@ 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 __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var claim_due_automations_use_case_exports = {};
|
|
29
20
|
__export(claim_due_automations_use_case_exports, {
|
|
30
21
|
ClaimDueAutomationsUseCase: () => ClaimDueAutomationsUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(claim_due_automations_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_logger = require("../../../common/logger/index.js");
|
|
35
25
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
36
26
|
var import_repositories = require("../repositories");
|
|
@@ -41,8 +31,8 @@ var import_previous_run = require("../utils/previous-run");
|
|
|
41
31
|
var import_sync_automation_run = require("./sync-automation-run.use-case");
|
|
42
32
|
var import_runner_scope = require("../utils/runner-scope");
|
|
43
33
|
const DEFAULT_LIMIT = 10;
|
|
44
|
-
|
|
45
|
-
constructor(automationRepository, automationRunRepository, syncRun) {
|
|
34
|
+
class ClaimDueAutomationsUseCase extends import_base.BaseUseCase {
|
|
35
|
+
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository(), syncRun = new import_sync_automation_run.SyncAutomationRunUseCase()) {
|
|
46
36
|
super();
|
|
47
37
|
this.automationRepository = automationRepository;
|
|
48
38
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -85,15 +75,9 @@ let ClaimDueAutomationsUseCase = class extends import_base.BaseUseCase {
|
|
|
85
75
|
await this.automationRepository.setActiveRun(id, workerId, String(run._id), import_runner_scope.runnerScope);
|
|
86
76
|
claimed.push({ automation, run: run.toJSON() });
|
|
87
77
|
}
|
|
88
|
-
return {
|
|
78
|
+
return { claimed, skipped };
|
|
89
79
|
}
|
|
90
|
-
}
|
|
91
|
-
ClaimDueAutomationsUseCase = __decorateClass([
|
|
92
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
93
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
94
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository)),
|
|
95
|
-
__decorateParam(2, (0, import_tsyringe.inject)(import_sync_automation_run.SyncAutomationRunUseCase))
|
|
96
|
-
], ClaimDueAutomationsUseCase);
|
|
80
|
+
}
|
|
97
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
98
82
|
0 && (module.exports = {
|
|
99
83
|
ClaimDueAutomationsUseCase
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { Logger } from "../../../common/logger/index.js";
|
|
7
2
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
8
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
@@ -13,8 +8,8 @@ import { findPausedRun } from "../utils/previous-run";
|
|
|
13
8
|
import { SyncAutomationRunUseCase } from "./sync-automation-run.use-case";
|
|
14
9
|
import { runnerScope } from "../utils/runner-scope";
|
|
15
10
|
const DEFAULT_LIMIT = 10;
|
|
16
|
-
|
|
17
|
-
constructor(automationRepository, automationRunRepository, syncRun) {
|
|
11
|
+
class ClaimDueAutomationsUseCase extends BaseUseCase {
|
|
12
|
+
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository(), syncRun = new SyncAutomationRunUseCase()) {
|
|
18
13
|
super();
|
|
19
14
|
this.automationRepository = automationRepository;
|
|
20
15
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -57,15 +52,9 @@ let ClaimDueAutomationsUseCase = class extends BaseUseCase {
|
|
|
57
52
|
await this.automationRepository.setActiveRun(id, workerId, String(run._id), runnerScope);
|
|
58
53
|
claimed.push({ automation, run: run.toJSON() });
|
|
59
54
|
}
|
|
60
|
-
return {
|
|
55
|
+
return { claimed, skipped };
|
|
61
56
|
}
|
|
62
|
-
}
|
|
63
|
-
ClaimDueAutomationsUseCase = __decorateClass([
|
|
64
|
-
autoInjectable(),
|
|
65
|
-
__decorateParam(0, inject(AutomationRepository)),
|
|
66
|
-
__decorateParam(1, inject(AutomationRunRepository)),
|
|
67
|
-
__decorateParam(2, inject(SyncAutomationRunUseCase))
|
|
68
|
-
], ClaimDueAutomationsUseCase);
|
|
57
|
+
}
|
|
69
58
|
export {
|
|
70
59
|
ClaimDueAutomationsUseCase
|
|
71
60
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
@@ -12,16 +12,14 @@ export interface ClaimedRun {
|
|
|
12
12
|
automation: AutomationProps;
|
|
13
13
|
run: AutomationRunProps;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
}
|
|
15
|
+
export type Output = {
|
|
16
|
+
claimed: ClaimedRun[];
|
|
17
|
+
skipped: ClaimedRun[];
|
|
18
|
+
};
|
|
21
19
|
export declare class ClaimQueuedAutomationRunsUseCase extends BaseUseCase<Params, Output> {
|
|
22
|
-
private readonly automationRepository
|
|
23
|
-
private readonly automationRunRepository
|
|
24
|
-
private readonly syncRun
|
|
25
|
-
constructor(automationRepository?: AutomationRepository
|
|
20
|
+
private readonly automationRepository;
|
|
21
|
+
private readonly automationRunRepository;
|
|
22
|
+
private readonly syncRun;
|
|
23
|
+
constructor(automationRepository?: AutomationRepository, automationRunRepository?: AutomationRunRepository, syncRun?: SyncAutomationRunUseCase);
|
|
26
24
|
execute(params: Params): Promise<Output>;
|
|
27
25
|
}
|
|
@@ -16,21 +16,11 @@ 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 __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var claim_queued_automation_runs_use_case_exports = {};
|
|
29
20
|
__export(claim_queued_automation_runs_use_case_exports, {
|
|
30
21
|
ClaimQueuedAutomationRunsUseCase: () => ClaimQueuedAutomationRunsUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(claim_queued_automation_runs_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_entities = require("../entities");
|
|
36
26
|
var import_repositories = require("../repositories");
|
|
@@ -39,8 +29,8 @@ var import_settings = require("../utils/settings");
|
|
|
39
29
|
var import_sync_automation_run = require("./sync-automation-run.use-case");
|
|
40
30
|
var import_runner_scope = require("../utils/runner-scope");
|
|
41
31
|
const SCAN_LIMIT = 200;
|
|
42
|
-
|
|
43
|
-
constructor(automationRepository, automationRunRepository, syncRun) {
|
|
32
|
+
class ClaimQueuedAutomationRunsUseCase extends import_base.BaseUseCase {
|
|
33
|
+
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository(), syncRun = new import_sync_automation_run.SyncAutomationRunUseCase()) {
|
|
44
34
|
super();
|
|
45
35
|
this.automationRepository = automationRepository;
|
|
46
36
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -92,15 +82,9 @@ let ClaimQueuedAutomationRunsUseCase = class extends import_base.BaseUseCase {
|
|
|
92
82
|
await this.automationRepository.setActiveRun(automationId, workerId, String(started._id), import_runner_scope.runnerScope);
|
|
93
83
|
claimed.push({ automation, run: started });
|
|
94
84
|
}
|
|
95
|
-
return {
|
|
85
|
+
return { claimed, skipped };
|
|
96
86
|
}
|
|
97
|
-
}
|
|
98
|
-
ClaimQueuedAutomationRunsUseCase = __decorateClass([
|
|
99
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
100
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
101
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository)),
|
|
102
|
-
__decorateParam(2, (0, import_tsyringe.inject)(import_sync_automation_run.SyncAutomationRunUseCase))
|
|
103
|
-
], ClaimQueuedAutomationRunsUseCase);
|
|
87
|
+
}
|
|
104
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
89
|
0 && (module.exports = {
|
|
106
90
|
ClaimQueuedAutomationRunsUseCase
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { AutomationRun } from "../entities";
|
|
8
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
@@ -11,8 +6,8 @@ import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
|
11
6
|
import { SyncAutomationRunUseCase } from "./sync-automation-run.use-case";
|
|
12
7
|
import { runnerScope } from "../utils/runner-scope";
|
|
13
8
|
const SCAN_LIMIT = 200;
|
|
14
|
-
|
|
15
|
-
constructor(automationRepository, automationRunRepository, syncRun) {
|
|
9
|
+
class ClaimQueuedAutomationRunsUseCase extends BaseUseCase {
|
|
10
|
+
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository(), syncRun = new SyncAutomationRunUseCase()) {
|
|
16
11
|
super();
|
|
17
12
|
this.automationRepository = automationRepository;
|
|
18
13
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -64,15 +59,9 @@ let ClaimQueuedAutomationRunsUseCase = class extends BaseUseCase {
|
|
|
64
59
|
await this.automationRepository.setActiveRun(automationId, workerId, String(started._id), runnerScope);
|
|
65
60
|
claimed.push({ automation, run: started });
|
|
66
61
|
}
|
|
67
|
-
return {
|
|
62
|
+
return { claimed, skipped };
|
|
68
63
|
}
|
|
69
|
-
}
|
|
70
|
-
ClaimQueuedAutomationRunsUseCase = __decorateClass([
|
|
71
|
-
autoInjectable(),
|
|
72
|
-
__decorateParam(0, inject(AutomationRepository)),
|
|
73
|
-
__decorateParam(1, inject(AutomationRunRepository)),
|
|
74
|
-
__decorateParam(2, inject(SyncAutomationRunUseCase))
|
|
75
|
-
], ClaimQueuedAutomationRunsUseCase);
|
|
64
|
+
}
|
|
76
65
|
export {
|
|
77
66
|
ClaimQueuedAutomationRunsUseCase
|
|
78
67
|
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationPayload, AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
payload?: AutomationPayload;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
data: AutomationProps;
|
|
9
|
-
}
|
|
7
|
+
export type Output = AutomationProps;
|
|
10
8
|
export declare class CreateAutomationUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
-
private readonly automationRepository
|
|
12
|
-
constructor(automationRepository?: AutomationRepository
|
|
9
|
+
private readonly automationRepository;
|
|
10
|
+
constructor(automationRepository?: AutomationRepository);
|
|
13
11
|
execute(params: Params): Promise<Output>;
|
|
14
12
|
}
|
|
@@ -16,28 +16,18 @@ 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 __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var create_automation_use_case_exports = {};
|
|
29
20
|
__export(create_automation_use_case_exports, {
|
|
30
21
|
CreateAutomationUseCase: () => CreateAutomationUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(create_automation_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_repositories = require("../../../common/repositories/index.js");
|
|
36
26
|
var import_entities = require("../entities");
|
|
37
27
|
var import_repositories2 = require("../repositories");
|
|
38
28
|
var import_automation_fields = require("../utils/automation-fields");
|
|
39
|
-
|
|
40
|
-
constructor(automationRepository) {
|
|
29
|
+
class CreateAutomationUseCase extends import_base.BaseUseCase {
|
|
30
|
+
constructor(automationRepository = new import_repositories2.AutomationRepository()) {
|
|
41
31
|
super();
|
|
42
32
|
this.automationRepository = automationRepository;
|
|
43
33
|
}
|
|
@@ -58,14 +48,10 @@ let CreateAutomationUseCase = class extends import_base.BaseUseCase {
|
|
|
58
48
|
automation.scheduleNextRun();
|
|
59
49
|
const schedule = automation.triggers?.schedule;
|
|
60
50
|
if (schedule?.enabled && !schedule.nextRunAt) throw new Error("The date of the recurrence has already passed");
|
|
61
|
-
await this.automationRepository
|
|
62
|
-
return
|
|
51
|
+
await this.automationRepository.create(automation, params.scope ?? import_repositories.Scope.canEdit(currentUser));
|
|
52
|
+
return automation.toJSON();
|
|
63
53
|
}
|
|
64
|
-
}
|
|
65
|
-
CreateAutomationUseCase = __decorateClass([
|
|
66
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
67
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRepository))
|
|
68
|
-
], CreateAutomationUseCase);
|
|
54
|
+
}
|
|
69
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
56
|
0 && (module.exports = {
|
|
71
57
|
CreateAutomationUseCase
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { Scope } from "../../../common/repositories/index.js";
|
|
8
3
|
import { Automation } from "../entities";
|
|
9
4
|
import { AutomationRepository } from "../repositories";
|
|
10
5
|
import { readAutomationFields, assertModel } from "../utils/automation-fields";
|
|
11
|
-
|
|
12
|
-
constructor(automationRepository) {
|
|
6
|
+
class CreateAutomationUseCase extends BaseUseCase {
|
|
7
|
+
constructor(automationRepository = new AutomationRepository()) {
|
|
13
8
|
super();
|
|
14
9
|
this.automationRepository = automationRepository;
|
|
15
10
|
}
|
|
@@ -30,14 +25,10 @@ let CreateAutomationUseCase = class extends BaseUseCase {
|
|
|
30
25
|
automation.scheduleNextRun();
|
|
31
26
|
const schedule = automation.triggers?.schedule;
|
|
32
27
|
if (schedule?.enabled && !schedule.nextRunAt) throw new Error("The date of the recurrence has already passed");
|
|
33
|
-
await this.automationRepository
|
|
34
|
-
return
|
|
28
|
+
await this.automationRepository.create(automation, params.scope ?? Scope.canEdit(currentUser));
|
|
29
|
+
return automation.toJSON();
|
|
35
30
|
}
|
|
36
|
-
}
|
|
37
|
-
CreateAutomationUseCase = __decorateClass([
|
|
38
|
-
autoInjectable(),
|
|
39
|
-
__decorateParam(0, inject(AutomationRepository))
|
|
40
|
-
], CreateAutomationUseCase);
|
|
31
|
+
}
|
|
41
32
|
export {
|
|
42
33
|
CreateAutomationUseCase
|
|
43
34
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
id: string;
|
|
6
6
|
hardDelete?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
export type Output = AutomationProps | null | {
|
|
9
|
+
deletedCount: number;
|
|
10
|
+
};
|
|
11
11
|
export declare class DeleteAutomationUseCase extends BaseUseCase<Params, Output> {
|
|
12
|
-
private readonly automationRepository
|
|
13
|
-
constructor(automationRepository?: AutomationRepository
|
|
12
|
+
private readonly automationRepository;
|
|
13
|
+
constructor(automationRepository?: AutomationRepository);
|
|
14
14
|
execute(params: Params): Promise<Output>;
|
|
15
15
|
}
|