openloops 0.5.0 → 0.7.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/CHANGELOG.md +60 -0
- package/README.md +3 -2
- 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 +7 -25
- package/dist/common/base/base.entity.js +26 -133
- package/dist/common/base/base.entity.mjs +26 -128
- package/dist/common/base/base.use-case.d.ts +3 -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/index.d.ts +1 -0
- package/dist/common/base/index.js +3 -1
- package/dist/common/base/index.mjs +1 -0
- package/dist/common/base/share.d.ts +12 -0
- package/dist/common/base/share.js +45 -0
- package/dist/common/base/share.mjs +20 -0
- 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/index.d.ts +1 -0
- package/dist/common/repositories/index.js +3 -1
- package/dist/common/repositories/index.mjs +1 -0
- package/dist/common/repositories/mongo-db.client.mjs +0 -1
- package/dist/common/repositories/mongo-db.repository.d.ts +42 -11
- package/dist/common/repositories/mongo-db.repository.js +152 -42
- package/dist/common/repositories/mongo-db.repository.mjs +152 -43
- package/dist/common/repositories/scope.d.ts +19 -0
- package/dist/common/repositories/scope.js +63 -0
- package/dist/common/repositories/scope.mjs +39 -0
- 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.mjs +0 -1
- package/dist/db/indexes/refresh-tokens.d.ts +2 -0
- package/dist/{common/decorators/admin-only/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 +0 -1
- package/dist/harness/agent.js +14 -14
- package/dist/harness/agent.mjs +14 -15
- 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/{common/decorators/owner-only/index.js → services/authentication/helpers/auth-config.js} +19 -5
- 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.d.ts +3 -3
- package/dist/services/authentication/repositories/revoked-token.repository.js +9 -20
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +9 -15
- 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 +6 -19
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +6 -14
- 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 -53
- package/dist/services/authentication/use-cases/login.use-case.mjs +18 -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 -25
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +11 -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.d.ts +10 -10
- package/dist/services/automations/repositories/automation-run.repository.js +26 -38
- package/dist/services/automations/repositories/automation-run.repository.mjs +26 -33
- package/dist/services/automations/repositories/automation.repository.d.ts +14 -13
- package/dist/services/automations/repositories/automation.repository.js +52 -54
- package/dist/services/automations/repositories/automation.repository.mjs +52 -49
- package/dist/services/automations/runner/automation-runner.d.ts +3 -0
- package/dist/services/automations/runner/automation-runner.js +8 -9
- package/dist/services/automations/runner/automation-runner.mjs +8 -10
- 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 +8 -21
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +8 -16
- 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 +11 -26
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +11 -21
- 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 +13 -28
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +13 -23
- 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 +7 -22
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +6 -16
- 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 +10 -27
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +9 -21
- 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 +9 -23
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +9 -18
- 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 +8 -21
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +7 -15
- 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 +8 -22
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +7 -16
- 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 +8 -20
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +8 -15
- 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 +7 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +7 -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 +7 -19
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +7 -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 +15 -29
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +15 -24
- 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 +6 -19
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +6 -14
- 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 +10 -23
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +10 -18
- 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 +11 -25
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +10 -19
- 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 +12 -25
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +12 -20
- 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 +13 -27
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +13 -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 +8 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +8 -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 +13 -26
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +12 -20
- 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.d.ts +2 -0
- package/dist/services/automations/utils/open-run.js +2 -2
- package/dist/services/automations/utils/open-run.mjs +2 -3
- package/dist/services/automations/utils/previous-run.js +4 -3
- package/dist/services/automations/utils/previous-run.mjs +4 -4
- package/dist/services/automations/utils/runner-scope.d.ts +3 -0
- package/dist/{common/base/utils/flatten-object.js → services/automations/utils/runner-scope.js} +10 -23
- package/dist/services/automations/utils/runner-scope.mjs +7 -0
- 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.d.ts +7 -6
- package/dist/services/chats/repositories/chat.repository.js +19 -29
- package/dist/services/chats/repositories/chat.repository.mjs +19 -24
- 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 +7 -22
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +6 -16
- 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 +10 -26
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +8 -16
- 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 +8 -24
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +7 -18
- 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 +7 -20
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +7 -15
- 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 +7 -19
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +7 -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 +10 -30
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +9 -24
- 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.d.ts +7 -6
- package/dist/services/llmcalls/repositories/llmcall.repository.js +19 -29
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +19 -24
- 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 +7 -22
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +6 -16
- 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 +10 -26
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +7 -15
- 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 +8 -21
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +7 -15
- 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 +6 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +6 -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 +9 -21
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +8 -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 +7 -20
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +7 -15
- 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 +9 -25
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +8 -19
- 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/entities/mcp-manifest.mjs +0 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +0 -1
- 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 -7
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +21 -31
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +21 -26
- 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 +7 -24
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +6 -18
- 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 +11 -26
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +10 -20
- 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 +10 -26
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +7 -15
- 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 +7 -20
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +6 -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 +5 -19
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +5 -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 +12 -31
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +11 -25
- 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 +13 -27
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +12 -21
- 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.d.ts +4 -4
- package/dist/services/tasks/repositories/agent-action.repository.js +12 -26
- package/dist/services/tasks/repositories/agent-action.repository.mjs +12 -21
- package/dist/services/tasks/repositories/agent-task.repository.d.ts +5 -5
- package/dist/services/tasks/repositories/agent-task.repository.js +14 -28
- package/dist/services/tasks/repositories/agent-task.repository.mjs +14 -23
- 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 +7 -22
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +6 -16
- 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 +7 -22
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +6 -16
- 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 +8 -21
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +7 -15
- 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 +8 -20
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +8 -15
- 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 +8 -20
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +8 -15
- 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 +8 -24
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +7 -18
- 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 +8 -24
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +7 -18
- 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.d.ts +3 -3
- package/dist/services/traces/repositories/agent-trace.repository.js +8 -19
- package/dist/services/traces/repositories/agent-trace.repository.mjs +8 -14
- 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 +8 -26
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +7 -20
- 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 +8 -20
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +8 -15
- package/dist/services/users/entities/user-acquisition.js +4 -17
- package/dist/services/users/entities/user-acquisition.mjs +4 -12
- 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 +4 -17
- package/dist/services/users/entities/user-marketing.mjs +4 -12
- 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 -25
- package/dist/services/users/entities/user.entity.mjs +9 -20
- 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 +10 -7
- package/dist/services/users/repositories/user.repository.js +34 -29
- package/dist/services/users/repositories/user.repository.mjs +34 -24
- 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 -7
- package/dist/services/users/use-cases/create-user.use-case.js +8 -22
- package/dist/services/users/use-cases/create-user.use-case.mjs +7 -16
- 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 +10 -26
- package/dist/services/users/use-cases/delete-user.use-case.mjs +9 -20
- 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 +9 -21
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +8 -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 +7 -20
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +7 -15
- 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 +11 -26
- package/dist/services/users/use-cases/update-user.use-case.mjs +10 -20
- 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.d.ts +8 -8
- package/dist/services/workspaces/repositories/workspace-item.repository.js +20 -32
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +20 -27
- 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 +11 -22
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +10 -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 +8 -21
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +7 -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 +7 -19
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +7 -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 +14 -28
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +13 -22
- 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 +7 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +7 -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/README.md +2 -1
- package/docs/authentication.md +95 -16
- package/docs/authorization.md +77 -0
- package/docs/automations.md +10 -9
- package/docs/chats.md +1 -1
- package/docs/configuration.md +1 -1
- package/docs/integration-guide.md +9 -11
- package/docs/llms.txt +1 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/usage.md +5 -5
- package/docs/users.md +7 -5
- 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 +4 -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-now.ts +3 -1
- package/examples/automations/update-automation.ts +2 -2
- package/examples/chats/delete-chat.ts +1 -1
- 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/decide-mcp.ts +3 -3
- package/examples/mcps/list-all-mcps.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/create-user.ts +2 -1
- package/examples/users/list-users.ts +1 -0
- package/examples/users/set-default-model.ts +1 -1
- package/package.json +2 -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/admin-only/admin-only.d.ts +0 -2
- package/dist/common/decorators/admin-only/admin-only.js +0 -52
- package/dist/common/decorators/admin-only/admin-only.mjs +0 -28
- package/dist/common/decorators/admin-only/index.d.ts +0 -1
- package/dist/common/decorators/admin-only/index.mjs +0 -1
- package/dist/common/decorators/index.d.ts +0 -3
- package/dist/common/decorators/index.js +0 -26
- package/dist/common/decorators/index.mjs +0 -3
- package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
- package/dist/common/decorators/mask-in-logs/index.js +0 -22
- 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
- package/dist/common/decorators/owner-only/index.d.ts +0 -1
- package/dist/common/decorators/owner-only/index.mjs +0 -1
- package/dist/common/decorators/owner-only/owner-only.d.ts +0 -2
- package/dist/common/decorators/owner-only/owner-only.js +0 -52
- package/dist/common/decorators/owner-only/owner-only.mjs +0 -28
|
@@ -16,111 +16,109 @@ 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
19
|
var automation_repository_exports = {};
|
|
28
20
|
__export(automation_repository_exports, {
|
|
29
21
|
AutomationRepository: () => AutomationRepository
|
|
30
22
|
});
|
|
31
23
|
module.exports = __toCommonJS(automation_repository_exports);
|
|
32
|
-
var import_tsyringe = require("tsyringe");
|
|
33
24
|
var import_mongodb = require("mongodb");
|
|
25
|
+
var import_utils = require("../../../common/base/utils/index.js");
|
|
34
26
|
var import_repositories = require("../../../common/repositories/index.js");
|
|
35
27
|
var import_database_name = require("../../../common/utils/database-name.js");
|
|
36
|
-
|
|
28
|
+
class AutomationRepository {
|
|
37
29
|
_ = new import_repositories.MongoRepository({
|
|
38
30
|
database: (0, import_database_name.getDatabaseName)(),
|
|
39
|
-
collection: "automations"
|
|
31
|
+
collection: "automations",
|
|
32
|
+
scoped: true
|
|
40
33
|
});
|
|
41
|
-
async create(automation) {
|
|
42
|
-
const
|
|
43
|
-
|
|
34
|
+
async create(automation, scope) {
|
|
35
|
+
const { _id, ownerId, createdAt, createdBy } = await this._.createOne({ payload: automation.toJSON(), scope });
|
|
36
|
+
Object.assign(automation, { _id, ownerId, createdAt, createdBy });
|
|
44
37
|
return automation;
|
|
45
38
|
}
|
|
46
|
-
async update(automation, options) {
|
|
39
|
+
async update(automation, scope, options) {
|
|
47
40
|
if (options && typeof options.expectedVersion !== "number") throw new Error("[AutomationRepository] The expected version is required to check for conflicts");
|
|
48
|
-
return await this._.
|
|
49
|
-
where: { _id: automation._id },
|
|
50
|
-
payload: automation.toFlatDocument(),
|
|
51
|
-
expectedVersion: options?.expectedVersion
|
|
52
|
-
});
|
|
41
|
+
return await this._.patchOne({ scope, where: { _id: automation._id }, ...(0, import_utils.entityPatch)(automation), expectedVersion: options?.expectedVersion });
|
|
53
42
|
}
|
|
54
|
-
async findById(id) {
|
|
55
|
-
return await this._.findOne({ where: { _id: this._.parseId(id) } });
|
|
43
|
+
async findById(id, scope) {
|
|
44
|
+
return await this._.findOne({ scope, where: { _id: this._.parseId(id) } });
|
|
56
45
|
}
|
|
57
|
-
async findByOwner(ownerId, options) {
|
|
58
|
-
return await this._.findMany({ where: { ownerId: new import_mongodb.ObjectId(ownerId) }, options });
|
|
46
|
+
async findByOwner(ownerId, scope, options) {
|
|
47
|
+
return await this._.findMany({ scope, where: { ownerId: new import_mongodb.ObjectId(ownerId) }, options });
|
|
59
48
|
}
|
|
60
|
-
async
|
|
61
|
-
return await this._.
|
|
49
|
+
async softDeleteById(id, scope) {
|
|
50
|
+
return await this._.softDelete({ scope, where: { _id: this._.parseId(id) }, unset: { "triggers.schedule.nextRunAt": "" } });
|
|
62
51
|
}
|
|
63
|
-
async
|
|
52
|
+
async deleteById(id, scope) {
|
|
53
|
+
return await this._.deleteOne({ scope, where: { _id: this._.parseId(id) } });
|
|
54
|
+
}
|
|
55
|
+
async findDue(now, limit, scope) {
|
|
64
56
|
return await this._.findMany({
|
|
57
|
+
scope,
|
|
65
58
|
where: { "triggers.schedule.enabled": true, "triggers.schedule.nextRunAt": { $lte: now }, ...this.unlocked(now) },
|
|
66
59
|
options: { page: 1, limit, sortBy: { "triggers.schedule.nextRunAt": 1 } }
|
|
67
60
|
});
|
|
68
61
|
}
|
|
69
|
-
async claim(params) {
|
|
62
|
+
async claim(params, scope) {
|
|
70
63
|
const { id, workerId, now, leaseMs, nextRunAt } = params;
|
|
71
|
-
return await this._.
|
|
64
|
+
return await this._.patchOne({
|
|
65
|
+
scope,
|
|
72
66
|
where: { _id: this._.parseId(id), "triggers.schedule.enabled": true, "triggers.schedule.nextRunAt": { $lte: now }, ...this.unlocked(now) },
|
|
73
|
-
|
|
67
|
+
set: {
|
|
74
68
|
lockedBy: workerId,
|
|
75
69
|
lockedUntil: new Date(now.getTime() + leaseMs),
|
|
76
|
-
...nextRunAt ? { "triggers.schedule.nextRunAt": nextRunAt } : {
|
|
77
|
-
}
|
|
70
|
+
...nextRunAt ? { "triggers.schedule.nextRunAt": nextRunAt } : {}
|
|
71
|
+
},
|
|
72
|
+
unset: nextRunAt ? {} : { "triggers.schedule.nextRunAt": "" }
|
|
78
73
|
});
|
|
79
74
|
}
|
|
80
|
-
async claimManual(params) {
|
|
75
|
+
async claimManual(params, scope) {
|
|
81
76
|
const { id, workerId, now, leaseMs } = params;
|
|
82
|
-
return await this._.
|
|
77
|
+
return await this._.patchOne({
|
|
78
|
+
scope,
|
|
83
79
|
where: { _id: this._.parseId(id), ...this.unlocked(now) },
|
|
84
|
-
|
|
80
|
+
set: { lockedBy: workerId, lockedUntil: new Date(now.getTime() + leaseMs) }
|
|
85
81
|
});
|
|
86
82
|
}
|
|
87
|
-
async setActiveRun(id, workerId, runId) {
|
|
88
|
-
return await this._.
|
|
83
|
+
async setActiveRun(id, workerId, runId, scope) {
|
|
84
|
+
return await this._.patchOne({
|
|
85
|
+
scope,
|
|
89
86
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
90
|
-
|
|
87
|
+
set: { activeRunId: this._.parseId(runId) }
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
|
-
async settleRun(id, runId, status, at) {
|
|
94
|
-
return await this._.
|
|
90
|
+
async settleRun(id, runId, status, at, scope) {
|
|
91
|
+
return await this._.patchOne({
|
|
92
|
+
scope,
|
|
95
93
|
where: { _id: this._.parseId(id), activeRunId: this._.parseId(runId) },
|
|
96
|
-
|
|
94
|
+
set: { lastRunStatus: status, lastRunAt: at },
|
|
95
|
+
unset: { activeRunId: "" }
|
|
97
96
|
});
|
|
98
97
|
}
|
|
99
|
-
async renewLease(id, workerId, until) {
|
|
100
|
-
return await this._.
|
|
98
|
+
async renewLease(id, workerId, until, scope) {
|
|
99
|
+
return await this._.patchOne({
|
|
100
|
+
scope,
|
|
101
101
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
102
|
-
|
|
102
|
+
set: { lockedUntil: until }
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
async release(id, workerId, result) {
|
|
105
|
+
async release(id, workerId, result, scope) {
|
|
106
106
|
const { activeRunId, lastRunAt, lastRunStatus } = result;
|
|
107
|
-
return await this._.
|
|
107
|
+
return await this._.patchOne({
|
|
108
|
+
scope,
|
|
108
109
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
109
|
-
|
|
110
|
+
set: {
|
|
110
111
|
...lastRunAt ? { lastRunAt } : {},
|
|
111
112
|
...lastRunStatus ? { lastRunStatus } : {},
|
|
112
|
-
...activeRunId ? { activeRunId } : {}
|
|
113
|
-
|
|
114
|
-
}
|
|
113
|
+
...activeRunId ? { activeRunId } : {}
|
|
114
|
+
},
|
|
115
|
+
unset: { lockedBy: "", lockedUntil: "", ...activeRunId ? {} : { activeRunId: "" } }
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
unlocked(now) {
|
|
118
119
|
return { $or: [{ lockedUntil: { $exists: false } }, { lockedUntil: null }, { lockedUntil: { $lte: now } }] };
|
|
119
120
|
}
|
|
120
|
-
}
|
|
121
|
-
AutomationRepository = __decorateClass([
|
|
122
|
-
(0, import_tsyringe.autoInjectable)()
|
|
123
|
-
], AutomationRepository);
|
|
121
|
+
}
|
|
124
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
125
123
|
0 && (module.exports = {
|
|
126
124
|
AutomationRepository
|
|
@@ -1,98 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass
|
|
3
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
4
|
-
import { autoInjectable } from "tsyringe";
|
|
5
1
|
import { ObjectId } from "mongodb";
|
|
2
|
+
import { entityPatch } from "../../../common/base/utils/index.js";
|
|
6
3
|
import { MongoRepository } from "../../../common/repositories/index.js";
|
|
7
4
|
import { getDatabaseName } from "../../../common/utils/database-name.js";
|
|
8
|
-
|
|
5
|
+
class AutomationRepository {
|
|
9
6
|
_ = new MongoRepository({
|
|
10
7
|
database: getDatabaseName(),
|
|
11
|
-
collection: "automations"
|
|
8
|
+
collection: "automations",
|
|
9
|
+
scoped: true
|
|
12
10
|
});
|
|
13
|
-
async create(automation) {
|
|
14
|
-
const
|
|
15
|
-
|
|
11
|
+
async create(automation, scope) {
|
|
12
|
+
const { _id, ownerId, createdAt, createdBy } = await this._.createOne({ payload: automation.toJSON(), scope });
|
|
13
|
+
Object.assign(automation, { _id, ownerId, createdAt, createdBy });
|
|
16
14
|
return automation;
|
|
17
15
|
}
|
|
18
|
-
async update(automation, options) {
|
|
16
|
+
async update(automation, scope, options) {
|
|
19
17
|
if (options && typeof options.expectedVersion !== "number") throw new Error("[AutomationRepository] The expected version is required to check for conflicts");
|
|
20
|
-
return await this._.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
18
|
+
return await this._.patchOne({ scope, where: { _id: automation._id }, ...entityPatch(automation), expectedVersion: options?.expectedVersion });
|
|
19
|
+
}
|
|
20
|
+
async findById(id, scope) {
|
|
21
|
+
return await this._.findOne({ scope, where: { _id: this._.parseId(id) } });
|
|
25
22
|
}
|
|
26
|
-
async
|
|
27
|
-
return await this._.
|
|
23
|
+
async findByOwner(ownerId, scope, options) {
|
|
24
|
+
return await this._.findMany({ scope, where: { ownerId: new ObjectId(ownerId) }, options });
|
|
28
25
|
}
|
|
29
|
-
async
|
|
30
|
-
return await this._.
|
|
26
|
+
async softDeleteById(id, scope) {
|
|
27
|
+
return await this._.softDelete({ scope, where: { _id: this._.parseId(id) }, unset: { "triggers.schedule.nextRunAt": "" } });
|
|
31
28
|
}
|
|
32
|
-
async deleteById(id) {
|
|
33
|
-
return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
|
|
29
|
+
async deleteById(id, scope) {
|
|
30
|
+
return await this._.deleteOne({ scope, where: { _id: this._.parseId(id) } });
|
|
34
31
|
}
|
|
35
|
-
async findDue(now, limit) {
|
|
32
|
+
async findDue(now, limit, scope) {
|
|
36
33
|
return await this._.findMany({
|
|
34
|
+
scope,
|
|
37
35
|
where: { "triggers.schedule.enabled": true, "triggers.schedule.nextRunAt": { $lte: now }, ...this.unlocked(now) },
|
|
38
36
|
options: { page: 1, limit, sortBy: { "triggers.schedule.nextRunAt": 1 } }
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
|
-
async claim(params) {
|
|
39
|
+
async claim(params, scope) {
|
|
42
40
|
const { id, workerId, now, leaseMs, nextRunAt } = params;
|
|
43
|
-
return await this._.
|
|
41
|
+
return await this._.patchOne({
|
|
42
|
+
scope,
|
|
44
43
|
where: { _id: this._.parseId(id), "triggers.schedule.enabled": true, "triggers.schedule.nextRunAt": { $lte: now }, ...this.unlocked(now) },
|
|
45
|
-
|
|
44
|
+
set: {
|
|
46
45
|
lockedBy: workerId,
|
|
47
46
|
lockedUntil: new Date(now.getTime() + leaseMs),
|
|
48
|
-
...nextRunAt ? { "triggers.schedule.nextRunAt": nextRunAt } : {
|
|
49
|
-
}
|
|
47
|
+
...nextRunAt ? { "triggers.schedule.nextRunAt": nextRunAt } : {}
|
|
48
|
+
},
|
|
49
|
+
unset: nextRunAt ? {} : { "triggers.schedule.nextRunAt": "" }
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
async claimManual(params) {
|
|
52
|
+
async claimManual(params, scope) {
|
|
53
53
|
const { id, workerId, now, leaseMs } = params;
|
|
54
|
-
return await this._.
|
|
54
|
+
return await this._.patchOne({
|
|
55
|
+
scope,
|
|
55
56
|
where: { _id: this._.parseId(id), ...this.unlocked(now) },
|
|
56
|
-
|
|
57
|
+
set: { lockedBy: workerId, lockedUntil: new Date(now.getTime() + leaseMs) }
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
async setActiveRun(id, workerId, runId) {
|
|
60
|
-
return await this._.
|
|
60
|
+
async setActiveRun(id, workerId, runId, scope) {
|
|
61
|
+
return await this._.patchOne({
|
|
62
|
+
scope,
|
|
61
63
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
62
|
-
|
|
64
|
+
set: { activeRunId: this._.parseId(runId) }
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
async settleRun(id, runId, status, at) {
|
|
66
|
-
return await this._.
|
|
67
|
+
async settleRun(id, runId, status, at, scope) {
|
|
68
|
+
return await this._.patchOne({
|
|
69
|
+
scope,
|
|
67
70
|
where: { _id: this._.parseId(id), activeRunId: this._.parseId(runId) },
|
|
68
|
-
|
|
71
|
+
set: { lastRunStatus: status, lastRunAt: at },
|
|
72
|
+
unset: { activeRunId: "" }
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
|
-
async renewLease(id, workerId, until) {
|
|
72
|
-
return await this._.
|
|
75
|
+
async renewLease(id, workerId, until, scope) {
|
|
76
|
+
return await this._.patchOne({
|
|
77
|
+
scope,
|
|
73
78
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
74
|
-
|
|
79
|
+
set: { lockedUntil: until }
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
|
-
async release(id, workerId, result) {
|
|
82
|
+
async release(id, workerId, result, scope) {
|
|
78
83
|
const { activeRunId, lastRunAt, lastRunStatus } = result;
|
|
79
|
-
return await this._.
|
|
84
|
+
return await this._.patchOne({
|
|
85
|
+
scope,
|
|
80
86
|
where: { _id: this._.parseId(id), lockedBy: workerId },
|
|
81
|
-
|
|
87
|
+
set: {
|
|
82
88
|
...lastRunAt ? { lastRunAt } : {},
|
|
83
89
|
...lastRunStatus ? { lastRunStatus } : {},
|
|
84
|
-
...activeRunId ? { activeRunId } : {}
|
|
85
|
-
|
|
86
|
-
}
|
|
90
|
+
...activeRunId ? { activeRunId } : {}
|
|
91
|
+
},
|
|
92
|
+
unset: { lockedBy: "", lockedUntil: "", ...activeRunId ? {} : { activeRunId: "" } }
|
|
87
93
|
});
|
|
88
94
|
}
|
|
89
95
|
unlocked(now) {
|
|
90
96
|
return { $or: [{ lockedUntil: { $exists: false } }, { lockedUntil: null }, { lockedUntil: { $lte: now } }] };
|
|
91
97
|
}
|
|
92
|
-
}
|
|
93
|
-
AutomationRepository = __decorateClass([
|
|
94
|
-
autoInjectable()
|
|
95
|
-
], AutomationRepository);
|
|
98
|
+
}
|
|
96
99
|
export {
|
|
97
100
|
AutomationRepository
|
|
98
101
|
};
|
|
@@ -2,6 +2,7 @@ import { CurrentUser } from '../../../common/base/index.js';
|
|
|
2
2
|
import { AgentOptions } from '../../../harness/agent.js';
|
|
3
3
|
import { Chat } from '../../chats/entities/chat.entity.js';
|
|
4
4
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
5
|
+
import { Scope } from '../../../common/repositories/index.js';
|
|
5
6
|
export interface AutomationContext {
|
|
6
7
|
automation: AutomationProps;
|
|
7
8
|
currentUser: CurrentUser;
|
|
@@ -37,6 +38,8 @@ export declare class AutomationRunner {
|
|
|
37
38
|
tick(): Promise<void>;
|
|
38
39
|
runNow(params: {
|
|
39
40
|
automationId: string;
|
|
41
|
+
currentUser?: CurrentUser;
|
|
42
|
+
scope?: Scope;
|
|
40
43
|
}): Promise<{
|
|
41
44
|
run: AutomationRunProps;
|
|
42
45
|
}>;
|
|
@@ -40,7 +40,6 @@ var import_finish_automation_run = require("../use-cases/finish-automation-run.u
|
|
|
40
40
|
var import_attach_automation_run_chat = require("../use-cases/attach-automation-run-chat.use-case");
|
|
41
41
|
var import_renew_automation_lease = require("../use-cases/renew-automation-lease.use-case");
|
|
42
42
|
var import_sync_automation_runs = require("../use-cases/sync-automation-runs.use-case");
|
|
43
|
-
var import_tsyringe = require("tsyringe");
|
|
44
43
|
const DEFAULT_MAX_CONCURRENT_RUNS = 3;
|
|
45
44
|
const DEFAULT_STOP_TIMEOUT_MS = 3e4;
|
|
46
45
|
const PAUSED_STATUSES = ["awaiting_user_confirmation", "awaiting_user_input"];
|
|
@@ -82,22 +81,22 @@ class AutomationRunner {
|
|
|
82
81
|
async tick() {
|
|
83
82
|
const capacity = (this.options.maxConcurrentRuns ?? DEFAULT_MAX_CONCURRENT_RUNS) - this.inFlight.size;
|
|
84
83
|
try {
|
|
85
|
-
await
|
|
84
|
+
await new import_sync_automation_runs.SyncAutomationRunsUseCase().execute({});
|
|
86
85
|
} catch (error) {
|
|
87
86
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] Failed to sync the open runs");
|
|
88
87
|
}
|
|
89
88
|
if (capacity <= 0) return;
|
|
90
|
-
const
|
|
89
|
+
const data = await new import_claim_due_automations.ClaimDueAutomationsUseCase().execute({ workerId: this.workerId, limit: capacity, leaseMs: this.options.leaseMs ?? (0, import_settings.leaseMs)() });
|
|
91
90
|
for (const { automation, run } of data.skipped) await this.notify({ automation, run });
|
|
92
91
|
for (const { automation, run } of data.claimed) this.track(this.execute(automation, run));
|
|
93
92
|
const remaining = capacity - data.claimed.length;
|
|
94
93
|
if (remaining <= 0) return;
|
|
95
|
-
const
|
|
94
|
+
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
95
|
for (const { automation, run } of queued.skipped) await this.notify({ automation, run });
|
|
97
96
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
98
97
|
}
|
|
99
98
|
async runNow(params) {
|
|
100
|
-
const
|
|
99
|
+
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
100
|
this.track(this.execute(data.automation, data.run));
|
|
102
101
|
return { run: data.run };
|
|
103
102
|
}
|
|
@@ -123,7 +122,7 @@ class AutomationRunner {
|
|
|
123
122
|
const automationId = String(automation._id);
|
|
124
123
|
const runId = String(run._id);
|
|
125
124
|
const heartbeat = setInterval(() => {
|
|
126
|
-
|
|
125
|
+
new import_renew_automation_lease.RenewAutomationLeaseUseCase().execute({ automationId, workerId: this.workerId, leaseMs }).catch((error2) => {
|
|
127
126
|
this.logger.error({ error: error2?.message ?? error2, automationId }, "[AUTOMATIONS] Failed to renew the lease of an automation");
|
|
128
127
|
});
|
|
129
128
|
}, Math.max(Math.floor(leaseMs / 3), 1e3));
|
|
@@ -141,7 +140,7 @@ class AutomationRunner {
|
|
|
141
140
|
} finally {
|
|
142
141
|
clearInterval(heartbeat);
|
|
143
142
|
}
|
|
144
|
-
const
|
|
143
|
+
const data = await new import_finish_automation_run.FinishAutomationRunUseCase().execute({ runId, workerId: this.workerId, status, error });
|
|
145
144
|
await this.notify({ automation, run: data ?? run, chat });
|
|
146
145
|
}
|
|
147
146
|
async runAgent(automation, run) {
|
|
@@ -155,9 +154,9 @@ class AutomationRunner {
|
|
|
155
154
|
draft.settings?.setExecutionMode("autonomous");
|
|
156
155
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
157
156
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
158
|
-
const
|
|
157
|
+
const created = await (0, import_chats.createChat)({ payload: draft.toJSON(), currentUser });
|
|
159
158
|
const chatId = String(created?._id);
|
|
160
|
-
await
|
|
159
|
+
await new import_attach_automation_run_chat.AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
161
160
|
const result = await agent.run({
|
|
162
161
|
input: { message: (0, import_event_message.buildMessage)(automation.instructions, run.payload), chatId },
|
|
163
162
|
options: { executionMode: "autonomous", ...model },
|
|
@@ -1,4 +1,3 @@
|
|
|
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";
|
|
@@ -17,7 +16,6 @@ import { FinishAutomationRunUseCase } from "../use-cases/finish-automation-run.u
|
|
|
17
16
|
import { AttachAutomationRunChatUseCase } from "../use-cases/attach-automation-run-chat.use-case";
|
|
18
17
|
import { RenewAutomationLeaseUseCase } from "../use-cases/renew-automation-lease.use-case";
|
|
19
18
|
import { SyncAutomationRunsUseCase } from "../use-cases/sync-automation-runs.use-case";
|
|
20
|
-
import { container } from "tsyringe";
|
|
21
19
|
const DEFAULT_MAX_CONCURRENT_RUNS = 3;
|
|
22
20
|
const DEFAULT_STOP_TIMEOUT_MS = 3e4;
|
|
23
21
|
const PAUSED_STATUSES = ["awaiting_user_confirmation", "awaiting_user_input"];
|
|
@@ -59,22 +57,22 @@ class AutomationRunner {
|
|
|
59
57
|
async tick() {
|
|
60
58
|
const capacity = (this.options.maxConcurrentRuns ?? DEFAULT_MAX_CONCURRENT_RUNS) - this.inFlight.size;
|
|
61
59
|
try {
|
|
62
|
-
await
|
|
60
|
+
await new SyncAutomationRunsUseCase().execute({});
|
|
63
61
|
} catch (error) {
|
|
64
62
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] Failed to sync the open runs");
|
|
65
63
|
}
|
|
66
64
|
if (capacity <= 0) return;
|
|
67
|
-
const
|
|
65
|
+
const data = await new ClaimDueAutomationsUseCase().execute({ workerId: this.workerId, limit: capacity, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
68
66
|
for (const { automation, run } of data.skipped) await this.notify({ automation, run });
|
|
69
67
|
for (const { automation, run } of data.claimed) this.track(this.execute(automation, run));
|
|
70
68
|
const remaining = capacity - data.claimed.length;
|
|
71
69
|
if (remaining <= 0) return;
|
|
72
|
-
const
|
|
70
|
+
const queued = await new ClaimQueuedAutomationRunsUseCase().execute({ workerId: this.workerId, limit: remaining, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
73
71
|
for (const { automation, run } of queued.skipped) await this.notify({ automation, run });
|
|
74
72
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
75
73
|
}
|
|
76
74
|
async runNow(params) {
|
|
77
|
-
const
|
|
75
|
+
const data = await new StartAutomationRunUseCase().execute({ automationId: params.automationId, currentUser: params.currentUser, scope: params.scope, workerId: this.workerId, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
78
76
|
this.track(this.execute(data.automation, data.run));
|
|
79
77
|
return { run: data.run };
|
|
80
78
|
}
|
|
@@ -100,7 +98,7 @@ class AutomationRunner {
|
|
|
100
98
|
const automationId = String(automation._id);
|
|
101
99
|
const runId = String(run._id);
|
|
102
100
|
const heartbeat = setInterval(() => {
|
|
103
|
-
|
|
101
|
+
new RenewAutomationLeaseUseCase().execute({ automationId, workerId: this.workerId, leaseMs }).catch((error2) => {
|
|
104
102
|
this.logger.error({ error: error2?.message ?? error2, automationId }, "[AUTOMATIONS] Failed to renew the lease of an automation");
|
|
105
103
|
});
|
|
106
104
|
}, Math.max(Math.floor(leaseMs / 3), 1e3));
|
|
@@ -118,7 +116,7 @@ class AutomationRunner {
|
|
|
118
116
|
} finally {
|
|
119
117
|
clearInterval(heartbeat);
|
|
120
118
|
}
|
|
121
|
-
const
|
|
119
|
+
const data = await new FinishAutomationRunUseCase().execute({ runId, workerId: this.workerId, status, error });
|
|
122
120
|
await this.notify({ automation, run: data ?? run, chat });
|
|
123
121
|
}
|
|
124
122
|
async runAgent(automation, run) {
|
|
@@ -132,9 +130,9 @@ class AutomationRunner {
|
|
|
132
130
|
draft.settings?.setExecutionMode("autonomous");
|
|
133
131
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
134
132
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
135
|
-
const
|
|
133
|
+
const created = await createChat({ payload: draft.toJSON(), currentUser });
|
|
136
134
|
const chatId = String(created?._id);
|
|
137
|
-
await
|
|
135
|
+
await new AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
138
136
|
const result = await agent.run({
|
|
139
137
|
input: { message: buildMessage(automation.instructions, run.payload), chatId },
|
|
140
138
|
options: { executionMode: "autonomous", ...model },
|
|
@@ -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,42 +16,29 @@ 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
|
-
|
|
38
|
-
|
|
27
|
+
var import_runner_scope = require("../utils/runner-scope");
|
|
28
|
+
class AttachAutomationRunChatUseCase extends import_base.BaseUseCase {
|
|
29
|
+
constructor(automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
39
30
|
super();
|
|
40
31
|
this.automationRunRepository = automationRunRepository;
|
|
41
32
|
}
|
|
42
33
|
automationRunRepository;
|
|
43
34
|
async execute(params) {
|
|
44
35
|
const { runId, chatId } = params;
|
|
45
|
-
const run = await this.automationRunRepository.findById(runId);
|
|
46
|
-
if (!run) return
|
|
47
|
-
const saved = await this.automationRunRepository.update(import_entities.AutomationRun.fromJSON({ ...run, chatId }));
|
|
48
|
-
return
|
|
36
|
+
const run = await this.automationRunRepository.findById(runId, import_runner_scope.runnerScope);
|
|
37
|
+
if (!run) return null;
|
|
38
|
+
const saved = await this.automationRunRepository.update(import_entities.AutomationRun.fromJSON({ ...run, chatId }), import_runner_scope.runnerScope);
|
|
39
|
+
return saved;
|
|
49
40
|
}
|
|
50
|
-
}
|
|
51
|
-
AttachAutomationRunChatUseCase = __decorateClass([
|
|
52
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
53
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
54
|
-
], AttachAutomationRunChatUseCase);
|
|
41
|
+
}
|
|
55
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
43
|
0 && (module.exports = {
|
|
57
44
|
AttachAutomationRunChatUseCase
|
|
@@ -1,29 +1,21 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
4
|
+
import { runnerScope } from "../utils/runner-scope";
|
|
5
|
+
class AttachAutomationRunChatUseCase extends BaseUseCase {
|
|
6
|
+
constructor(automationRunRepository = new AutomationRunRepository()) {
|
|
11
7
|
super();
|
|
12
8
|
this.automationRunRepository = automationRunRepository;
|
|
13
9
|
}
|
|
14
10
|
automationRunRepository;
|
|
15
11
|
async execute(params) {
|
|
16
12
|
const { runId, chatId } = params;
|
|
17
|
-
const run = await this.automationRunRepository.findById(runId);
|
|
18
|
-
if (!run) return
|
|
19
|
-
const saved = await this.automationRunRepository.update(AutomationRun.fromJSON({ ...run, chatId }));
|
|
20
|
-
return
|
|
13
|
+
const run = await this.automationRunRepository.findById(runId, runnerScope);
|
|
14
|
+
if (!run) return null;
|
|
15
|
+
const saved = await this.automationRunRepository.update(AutomationRun.fromJSON({ ...run, chatId }), runnerScope);
|
|
16
|
+
return saved;
|
|
21
17
|
}
|
|
22
|
-
}
|
|
23
|
-
AttachAutomationRunChatUseCase = __decorateClass([
|
|
24
|
-
autoInjectable(),
|
|
25
|
-
__decorateParam(0, inject(AutomationRunRepository))
|
|
26
|
-
], AttachAutomationRunChatUseCase);
|
|
18
|
+
}
|
|
27
19
|
export {
|
|
28
20
|
AttachAutomationRunChatUseCase
|
|
29
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
|
}
|