openloops 0.10.2 → 0.11.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 +25 -2
- package/README.md +14 -20
- package/dist/clients/llm/llm-client.d.ts +2 -2
- package/dist/clients/llm/llm-client.js +17 -18
- package/dist/clients/llm/llm-client.mjs +12 -13
- package/dist/clients/llm/llm-types.d.ts +2 -2
- package/dist/clients/llm/model-resolution.js +4 -5
- package/dist/clients/llm/model-resolution.mjs +1 -2
- package/dist/clients/serper/serper-client.js +3 -4
- package/dist/clients/serper/serper-client.mjs +1 -2
- package/dist/clients/slack/slack-client.js +2 -2
- package/dist/clients/slack/slack-client.mjs +1 -1
- package/dist/common/utils/number-setting.js +2 -2
- package/dist/common/utils/number-setting.mjs +1 -1
- package/dist/db/indexes/index.js +1 -5
- package/dist/db/indexes/index.mjs +1 -5
- package/dist/guardrails/guard.d.ts +4 -4
- package/dist/harness/actor-profile.d.ts +2 -0
- package/dist/{common/error/error-reporter.js → harness/actor-profile.js} +10 -13
- package/dist/harness/actor-profile.mjs +9 -0
- package/dist/harness/agent-loop.d.ts +4 -5
- package/dist/harness/agent.d.ts +7 -7
- package/dist/harness/agent.js +46 -46
- package/dist/harness/agent.mjs +44 -44
- package/dist/harness/default-model.d.ts +20 -0
- package/dist/harness/default-model.js +72 -0
- package/dist/harness/default-model.mjs +46 -0
- package/dist/harness/index.d.ts +2 -0
- package/dist/harness/index.js +8 -1
- package/dist/harness/index.mjs +5 -1
- package/dist/harness/tool-pipeline.d.ts +1 -1
- package/dist/harness/tool-pipeline.js +3 -3
- package/dist/harness/tool-pipeline.mjs +1 -1
- package/dist/harness/usage-limit.d.ts +2 -2
- package/dist/harness/usage-limit.js +5 -3
- package/dist/harness/usage-limit.mjs +5 -3
- package/dist/harness/workspace.d.ts +3 -3
- package/dist/harness/workspace.js +8 -8
- package/dist/harness/workspace.mjs +8 -8
- package/dist/loops/agi/loop.js +2 -2
- package/dist/loops/agi/loop.mjs +2 -2
- package/dist/services/automations/entities/automation-run.entity.d.ts +1 -1
- package/dist/services/automations/entities/automation-run.entity.js +4 -4
- package/dist/services/automations/entities/automation-run.entity.mjs +1 -1
- package/dist/services/automations/entities/automation.entity.d.ts +1 -1
- package/dist/services/automations/entities/automation.entity.js +3 -3
- package/dist/services/automations/entities/automation.entity.mjs +1 -1
- package/dist/services/automations/repositories/automation-run.repository.d.ts +1 -1
- package/dist/services/automations/repositories/automation-run.repository.js +5 -6
- package/dist/services/automations/repositories/automation-run.repository.mjs +2 -3
- package/dist/services/automations/repositories/automation.repository.d.ts +1 -1
- package/dist/services/automations/repositories/automation.repository.js +5 -6
- package/dist/services/automations/repositories/automation.repository.mjs +2 -3
- package/dist/services/automations/runner/automation-runner.d.ts +4 -4
- package/dist/services/automations/runner/automation-runner.js +16 -15
- package/dist/services/automations/runner/automation-runner.mjs +11 -10
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +2 -2
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/claim-due-automations.use-case.js +3 -4
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +1 -2
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/create-automation.use-case.js +8 -8
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -5
- package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -8
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +5 -5
- package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/finish-automation-run.use-case.js +2 -2
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +7 -7
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +7 -7
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +7 -7
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +9 -9
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +6 -6
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +9 -9
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +6 -6
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +3 -3
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +2 -2
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +2 -2
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +10 -11
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +7 -8
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +7 -7
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -5
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +2 -2
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/update-automation.use-case.js +8 -9
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +4 -5
- package/dist/services/automations/utils/event-token.d.ts +1 -0
- package/dist/services/automations/utils/event-token.js +9 -6
- package/dist/services/automations/utils/event-token.mjs +3 -1
- package/dist/services/automations/utils/open-run.d.ts +1 -1
- package/dist/services/automations/utils/runner-scope.d.ts +1 -1
- package/dist/services/automations/utils/runner-scope.js +3 -3
- package/dist/services/automations/utils/runner-scope.mjs +1 -1
- package/dist/services/chats/entities/chat-message.entity.d.ts +1 -1
- package/dist/services/chats/entities/chat-message.entity.js +3 -3
- package/dist/services/chats/entities/chat-message.entity.mjs +1 -1
- package/dist/services/chats/entities/chat.entity.d.ts +1 -1
- package/dist/services/chats/entities/chat.entity.js +4 -4
- package/dist/services/chats/entities/chat.entity.mjs +1 -1
- package/dist/services/chats/repositories/chat.repository.d.ts +1 -1
- package/dist/services/chats/repositories/chat.repository.js +5 -6
- package/dist/services/chats/repositories/chat.repository.mjs +2 -3
- package/dist/services/chats/use-cases/create-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/create-chat.use-case.js +7 -7
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -8
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +5 -5
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +7 -7
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/interrupt-execution.use-case.js +7 -7
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +7 -7
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +8 -8
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -5
- package/dist/services/chats/use-cases/update-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/update-chat.use-case.js +7 -7
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +4 -4
- package/dist/services/llmcalls/entities/llmcall.entity.d.ts +1 -1
- package/dist/services/llmcalls/entities/llmcall.entity.js +4 -4
- package/dist/services/llmcalls/entities/llmcall.entity.mjs +1 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.d.ts +1 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -6
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +2 -3
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -8
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +5 -5
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +9 -9
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +6 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +9 -9
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +6 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +2 -2
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +12 -10
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +9 -7
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +2 -2
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -5
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/admin-params.d.ts +5 -0
- package/dist/{common/logger/index.js → services/mcp-servers/admin/admin-params.js} +2 -8
- package/dist/services/mcp-servers/admin/admin-params.mjs +0 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +4 -3
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +8 -9
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +4 -5
- package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +1 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.js +2 -2
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +1 -1
- package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +1 -1
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +6 -7
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +2 -3
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -7
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +4 -4
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +7 -7
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +4 -4
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +2 -2
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +9 -10
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +5 -6
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -10
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +4 -5
- package/dist/services/tasks/entities/agent-action.entity.d.ts +1 -1
- package/dist/services/tasks/entities/agent-action.entity.js +6 -7
- package/dist/services/tasks/entities/agent-action.entity.mjs +1 -2
- package/dist/services/tasks/entities/agent-task.entity.d.ts +1 -1
- package/dist/services/tasks/entities/agent-task.entity.js +4 -4
- package/dist/services/tasks/entities/agent-task.entity.mjs +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.d.ts +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.js +5 -6
- package/dist/services/tasks/repositories/agent-action.repository.mjs +2 -3
- package/dist/services/tasks/repositories/agent-task.repository.d.ts +1 -1
- package/dist/services/tasks/repositories/agent-task.repository.js +5 -6
- package/dist/services/tasks/repositories/agent-task.repository.mjs +2 -3
- package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/create-agent-action.use-case.js +7 -7
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/create-agent-task.use-case.js +7 -7
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +7 -7
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +2 -2
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +9 -10
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +6 -7
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +2 -2
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +9 -10
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +6 -7
- package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/update-agent-action.use-case.js +7 -7
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/update-agent-task.use-case.js +7 -7
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +4 -4
- package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +1 -1
- package/dist/services/traces/entities/agent-trace-entry.entity.js +6 -6
- package/dist/services/traces/entities/agent-trace-entry.entity.mjs +1 -1
- package/dist/services/traces/repositories/agent-trace.repository.d.ts +1 -1
- package/dist/services/traces/repositories/agent-trace.repository.js +4 -4
- package/dist/services/traces/repositories/agent-trace.repository.mjs +2 -2
- package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +1 -1
- package/dist/services/traces/use-cases/create-agent-traces.use-case.js +7 -7
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +4 -4
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +2 -2
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +12 -13
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +6 -7
- package/dist/services/workspaces/entities/workspace-item.entity.d.ts +1 -1
- package/dist/services/workspaces/entities/workspace-item.entity.js +5 -5
- package/dist/services/workspaces/entities/workspace-item.entity.mjs +1 -1
- package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +1 -1
- package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -6
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +2 -3
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +2 -2
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -11
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +2 -2
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +6 -7
- package/dist/skills/runtime-context.d.ts +3 -3
- package/dist/skills/runtime-context.js +24 -21
- package/dist/skills/runtime-context.mjs +24 -21
- package/dist/skills/skill.d.ts +3 -3
- package/dist/skills/skill.js +5 -5
- package/dist/skills/skill.mjs +4 -4
- package/dist/tools/core/call-ai/call-ai.tool.js +2 -2
- package/dist/tools/core/call-ai/call-ai.tool.mjs +2 -2
- package/dist/tools/core/web-search/web-search.tool.js +1 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +1 -1
- package/dist/tools/tool.d.ts +2 -2
- package/dist/tools/tool.js +1 -1
- package/dist/tools/tool.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/agent.md +10 -10
- package/docs/authentication.md +15 -114
- package/docs/authorization.md +18 -18
- package/docs/automations.md +30 -28
- package/docs/chats.md +14 -14
- package/docs/configuration.md +14 -15
- package/docs/error-reporting.md +6 -6
- package/docs/guardrails.md +1 -1
- package/docs/integration-guide.md +12 -12
- package/docs/loops.md +2 -2
- package/docs/mcp-servers.md +15 -15
- package/docs/skills.md +1 -1
- package/docs/tools.md +2 -2
- package/docs/usage.md +5 -5
- package/docs/users.md +18 -91
- package/examples/automations/create-automation.ts +4 -4
- package/examples/automations/create-event-automation.ts +5 -5
- package/examples/automations/list-automation-runs.ts +7 -7
- package/examples/automations/list-automations.ts +4 -4
- 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 +6 -6
- package/examples/automations/run-automation-now.ts +4 -4
- package/examples/automations/run-automation-worker.ts +1 -1
- package/examples/automations/update-automation.ts +6 -6
- package/examples/chats/delete-chat.ts +6 -6
- package/examples/chats/get-chat-by-id.ts +6 -6
- package/examples/chats/list-autonomous-chats.ts +4 -4
- package/examples/chats/list-chats.ts +4 -4
- package/examples/chats/search-chats.ts +5 -5
- package/examples/errors/error-reporting.ts +6 -6
- package/examples/loops/custom-loop.ts +5 -5
- package/examples/mcps/create-mcp.ts +4 -4
- package/examples/mcps/decide-mcp.ts +7 -7
- package/examples/mcps/delete-mcp.ts +6 -6
- package/examples/mcps/get-mcp-by-id.ts +4 -4
- package/examples/mcps/internal-mcp-admin.ts +8 -8
- package/examples/mcps/internal-mcp.ts +5 -5
- package/examples/mcps/list-all-mcps.ts +4 -4
- package/examples/mcps/list-user-mcps.ts +4 -4
- package/examples/mcps/update-mcp.ts +4 -4
- package/examples/mcps/verify-mcp.ts +4 -4
- package/examples/run-agent/interrupt-agent.ts +5 -5
- package/examples/run-agent/run-agent-autonomous.ts +5 -5
- package/examples/run-agent/run-agent-multi-tenant.ts +10 -11
- package/examples/run-agent/run-agent-strict-mode.ts +5 -5
- package/examples/run-agent/run-agent-with-confirmation.ts +6 -6
- package/examples/run-agent/run-agent-with-fallback-model.ts +5 -5
- package/examples/run-agent/run-agent-with-fetch-url.ts +5 -5
- package/examples/run-agent/run-agent-with-guards.ts +5 -5
- package/examples/run-agent/run-agent-with-hooks.ts +5 -5
- package/examples/run-agent/run-agent-with-identity.ts +5 -5
- package/examples/run-agent/run-agent-with-model.ts +5 -5
- package/examples/run-agent/run-agent-with-slack.ts +5 -5
- package/examples/run-agent/run-agent-with-tools.ts +5 -5
- package/examples/run-agent/run-agent-with-usage-limit-stop.ts +5 -5
- package/examples/run-agent/run-agent-with-usage-limit.ts +5 -5
- package/examples/tools/basic-tool.ts +1 -1
- package/examples/tools/web-search-tool.ts +1 -1
- package/examples/usage/get-chat-usage.ts +4 -4
- package/examples/usage/get-message-usage.ts +4 -4
- package/examples/usage/get-usage-stats-by-range.ts +4 -4
- package/examples/usage/get-usage-stats.ts +4 -4
- package/examples/users/set-default-model.ts +12 -21
- package/package.json +7 -22
- package/dist/common/base/base.app.d.ts +0 -12
- package/dist/common/base/base.app.js +0 -57
- package/dist/common/base/base.app.mjs +0 -33
- package/dist/common/base/base.entity.d.ts +0 -38
- package/dist/common/base/base.entity.js +0 -100
- package/dist/common/base/base.entity.mjs +0 -76
- package/dist/common/base/base.use-case.d.ts +0 -11
- package/dist/common/base/base.use-case.js +0 -30
- package/dist/common/base/base.use-case.mjs +0 -6
- package/dist/common/base/current-session.d.ts +0 -129
- package/dist/common/base/current-session.js +0 -123
- package/dist/common/base/current-session.mjs +0 -98
- package/dist/common/base/current-user.d.ts +0 -16
- package/dist/common/base/current-user.js +0 -85
- package/dist/common/base/current-user.mjs +0 -61
- package/dist/common/base/index.d.ts +0 -3
- package/dist/common/base/index.js +0 -26
- package/dist/common/base/index.mjs +0 -3
- package/dist/common/base/share.d.ts +0 -12
- package/dist/common/base/share.js +0 -45
- package/dist/common/base/share.mjs +0 -20
- package/dist/common/base/utils/index.d.ts +0 -2
- package/dist/common/base/utils/index.js +0 -24
- package/dist/common/base/utils/index.mjs +0 -2
- package/dist/common/base/utils/is-plain-object.d.ts +0 -1
- package/dist/common/base/utils/is-plain-object.js +0 -32
- package/dist/common/base/utils/is-plain-object.mjs +0 -8
- package/dist/common/base/utils/to-patch.d.ts +0 -9
- package/dist/common/base/utils/to-patch.js +0 -46
- package/dist/common/base/utils/to-patch.mjs +0 -21
- package/dist/common/error/error-reporter.d.ts +0 -11
- package/dist/common/error/error-reporter.mjs +0 -11
- package/dist/common/error/http-error.d.ts +0 -11
- package/dist/common/error/http-error.js +0 -37
- package/dist/common/error/http-error.mjs +0 -13
- package/dist/common/error/index.d.ts +0 -3
- package/dist/common/error/index.js +0 -26
- package/dist/common/error/index.mjs +0 -3
- package/dist/common/error/reportError.d.ts +0 -2
- package/dist/common/error/reportError.js +0 -61
- package/dist/common/error/reportError.mjs +0 -37
- package/dist/common/error/sentry-client.d.ts +0 -10
- package/dist/common/error/sentry-client.js +0 -82
- package/dist/common/error/sentry-client.mjs +0 -57
- package/dist/common/index.d.ts +0 -6
- package/dist/common/index.js +0 -37
- package/dist/common/index.mjs +0 -9
- package/dist/common/logger/index.d.ts +0 -1
- package/dist/common/logger/index.mjs +0 -1
- package/dist/common/logger/pino.d.ts +0 -12
- package/dist/common/logger/pino.js +0 -79
- package/dist/common/logger/pino.mjs +0 -44
- package/dist/common/repositories/index.d.ts +0 -3
- package/dist/common/repositories/index.js +0 -26
- package/dist/common/repositories/index.mjs +0 -3
- package/dist/common/repositories/mongo-db.client.d.ts +0 -11
- package/dist/common/repositories/mongo-db.client.js +0 -83
- package/dist/common/repositories/mongo-db.client.mjs +0 -60
- package/dist/common/repositories/mongo-db.repository.d.ts +0 -130
- package/dist/common/repositories/mongo-db.repository.js +0 -357
- package/dist/common/repositories/mongo-db.repository.mjs +0 -332
- package/dist/common/repositories/scope.d.ts +0 -19
- package/dist/common/repositories/scope.js +0 -63
- package/dist/common/repositories/scope.mjs +0 -39
- package/dist/common/utils/config-context.d.ts +0 -3
- package/dist/common/utils/config-context.js +0 -33
- package/dist/common/utils/config-context.mjs +0 -8
- package/dist/common/utils/database-name.d.ts +0 -2
- package/dist/common/utils/database-name.js +0 -32
- package/dist/common/utils/database-name.mjs +0 -7
- package/dist/common/utils/secret-manager.d.ts +0 -17
- package/dist/common/utils/secret-manager.js +0 -124
- package/dist/common/utils/secret-manager.mjs +0 -89
- package/dist/db/indexes/refresh-tokens.d.ts +0 -2
- package/dist/db/indexes/refresh-tokens.js +0 -33
- package/dist/db/indexes/refresh-tokens.mjs +0 -9
- package/dist/db/indexes/revoked-tokens.d.ts +0 -2
- package/dist/db/indexes/revoked-tokens.js +0 -31
- package/dist/db/indexes/revoked-tokens.mjs +0 -7
- package/dist/services/authentication/entities/index.d.ts +0 -2
- package/dist/services/authentication/entities/index.js +0 -24
- package/dist/services/authentication/entities/index.mjs +0 -2
- package/dist/services/authentication/entities/refresh-token.entity.d.ts +0 -25
- package/dist/services/authentication/entities/refresh-token.entity.js +0 -75
- package/dist/services/authentication/entities/refresh-token.entity.mjs +0 -51
- package/dist/services/authentication/entities/revoked-token.entity.d.ts +0 -17
- package/dist/services/authentication/entities/revoked-token.entity.js +0 -67
- package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -43
- package/dist/services/authentication/helpers/auth-config.d.ts +0 -9
- package/dist/services/authentication/helpers/auth-config.js +0 -36
- package/dist/services/authentication/helpers/auth-config.mjs +0 -12
- package/dist/services/authentication/helpers/session-tokens.d.ts +0 -16
- package/dist/services/authentication/helpers/session-tokens.js +0 -60
- package/dist/services/authentication/helpers/session-tokens.mjs +0 -35
- package/dist/services/authentication/helpers/tokens.d.ts +0 -43
- package/dist/services/authentication/helpers/tokens.js +0 -113
- package/dist/services/authentication/helpers/tokens.mjs +0 -71
- package/dist/services/authentication/index.d.ts +0 -5
- package/dist/services/authentication/index.js +0 -47
- package/dist/services/authentication/index.mjs +0 -13
- package/dist/services/authentication/module.d.ts +0 -16
- package/dist/services/authentication/module.js +0 -81
- package/dist/services/authentication/module.mjs +0 -50
- package/dist/services/authentication/repositories/index.d.ts +0 -2
- package/dist/services/authentication/repositories/index.js +0 -24
- package/dist/services/authentication/repositories/index.mjs +0 -2
- package/dist/services/authentication/repositories/refresh-token.repository.d.ts +0 -10
- package/dist/services/authentication/repositories/refresh-token.repository.js +0 -60
- package/dist/services/authentication/repositories/refresh-token.repository.mjs +0 -36
- package/dist/services/authentication/repositories/revoked-token.repository.d.ts +0 -7
- package/dist/services/authentication/repositories/revoked-token.repository.js +0 -44
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +0 -20
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +0 -12
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +0 -40
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +0 -43
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +0 -19
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +0 -40
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +0 -42
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +0 -18
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +0 -18
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +0 -49
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +0 -25
- package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/issue-session.use-case.js +0 -48
- package/dist/services/authentication/use-cases/issue-session.use-case.mjs +0 -24
- package/dist/services/authentication/use-cases/login.use-case.d.ts +0 -20
- package/dist/services/authentication/use-cases/login.use-case.js +0 -54
- package/dist/services/authentication/use-cases/login.use-case.mjs +0 -30
- package/dist/services/authentication/use-cases/logout.use-case.d.ts +0 -14
- package/dist/services/authentication/use-cases/logout.use-case.js +0 -48
- package/dist/services/authentication/use-cases/logout.use-case.mjs +0 -24
- package/dist/services/authentication/use-cases/refresh.use-case.d.ts +0 -23
- package/dist/services/authentication/use-cases/refresh.use-case.js +0 -84
- package/dist/services/authentication/use-cases/refresh.use-case.mjs +0 -60
- package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +0 -15
- package/dist/services/authentication/use-cases/reset-password.use-case.js +0 -61
- package/dist/services/authentication/use-cases/reset-password.use-case.mjs +0 -37
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +0 -40
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +0 -12
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +0 -52
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +0 -28
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +0 -40
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +0 -16
- package/dist/services/users/entities/index.d.ts +0 -1
- package/dist/services/users/entities/index.js +0 -22
- package/dist/services/users/entities/index.mjs +0 -1
- package/dist/services/users/entities/user-acquisition.d.ts +0 -12
- package/dist/services/users/entities/user-acquisition.js +0 -42
- package/dist/services/users/entities/user-acquisition.mjs +0 -18
- package/dist/services/users/entities/user-country.d.ts +0 -11
- package/dist/services/users/entities/user-country.js +0 -44
- package/dist/services/users/entities/user-country.mjs +0 -20
- package/dist/services/users/entities/user-currency.d.ts +0 -13
- package/dist/services/users/entities/user-currency.js +0 -44
- package/dist/services/users/entities/user-currency.mjs +0 -20
- package/dist/services/users/entities/user-default-model.d.ts +0 -11
- package/dist/services/users/entities/user-default-model.js +0 -42
- package/dist/services/users/entities/user-default-model.mjs +0 -18
- package/dist/services/users/entities/user-email.value-object.d.ts +0 -6
- package/dist/services/users/entities/user-email.value-object.js +0 -43
- package/dist/services/users/entities/user-email.value-object.mjs +0 -19
- package/dist/services/users/entities/user-language.d.ts +0 -11
- package/dist/services/users/entities/user-language.js +0 -44
- package/dist/services/users/entities/user-language.mjs +0 -20
- package/dist/services/users/entities/user-marketing.d.ts +0 -9
- package/dist/services/users/entities/user-marketing.js +0 -40
- package/dist/services/users/entities/user-marketing.mjs +0 -16
- package/dist/services/users/entities/user-notification-preferences.d.ts +0 -11
- package/dist/services/users/entities/user-notification-preferences.js +0 -41
- package/dist/services/users/entities/user-notification-preferences.mjs +0 -17
- package/dist/services/users/entities/user-password.value-object.d.ts +0 -8
- package/dist/services/users/entities/user-password.value-object.js +0 -69
- package/dist/services/users/entities/user-password.value-object.mjs +0 -35
- package/dist/services/users/entities/user-permissions.d.ts +0 -21
- package/dist/services/users/entities/user-permissions.js +0 -59
- package/dist/services/users/entities/user-permissions.mjs +0 -35
- package/dist/services/users/entities/user-preferences.d.ts +0 -28
- package/dist/services/users/entities/user-preferences.js +0 -74
- package/dist/services/users/entities/user-preferences.mjs +0 -50
- package/dist/services/users/entities/user-report-preferences.d.ts +0 -16
- package/dist/services/users/entities/user-report-preferences.js +0 -56
- package/dist/services/users/entities/user-report-preferences.mjs +0 -32
- package/dist/services/users/entities/user-report-schedule.d.ts +0 -11
- package/dist/services/users/entities/user-report-schedule.js +0 -41
- package/dist/services/users/entities/user-report-schedule.mjs +0 -17
- package/dist/services/users/entities/user-timezone.d.ts +0 -11
- package/dist/services/users/entities/user-timezone.js +0 -44
- package/dist/services/users/entities/user-timezone.mjs +0 -20
- package/dist/services/users/entities/user.entity.d.ts +0 -42
- package/dist/services/users/entities/user.entity.js +0 -117
- package/dist/services/users/entities/user.entity.mjs +0 -92
- package/dist/services/users/index.d.ts +0 -3
- package/dist/services/users/index.js +0 -26
- package/dist/services/users/index.mjs +0 -3
- package/dist/services/users/module.d.ts +0 -12
- package/dist/services/users/module.js +0 -67
- package/dist/services/users/module.mjs +0 -38
- package/dist/services/users/repositories/index.d.ts +0 -1
- package/dist/services/users/repositories/index.js +0 -22
- package/dist/services/users/repositories/index.mjs +0 -1
- package/dist/services/users/repositories/user.repository.d.ts +0 -18
- package/dist/services/users/repositories/user.repository.js +0 -88
- package/dist/services/users/repositories/user.repository.mjs +0 -64
- package/dist/services/users/use-cases/change-password.use-case.d.ts +0 -15
- package/dist/services/users/use-cases/change-password.use-case.js +0 -52
- package/dist/services/users/use-cases/change-password.use-case.mjs +0 -28
- package/dist/services/users/use-cases/create-user.use-case.d.ts +0 -12
- package/dist/services/users/use-cases/create-user.use-case.js +0 -49
- package/dist/services/users/use-cases/create-user.use-case.mjs +0 -25
- package/dist/services/users/use-cases/delete-user.use-case.d.ts +0 -16
- package/dist/services/users/use-cases/delete-user.use-case.js +0 -48
- package/dist/services/users/use-cases/delete-user.use-case.mjs +0 -24
- package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +0 -12
- package/dist/services/users/use-cases/get-user-by-id.use-case.js +0 -43
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +0 -19
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +0 -17
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +0 -42
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +0 -18
- package/dist/services/users/use-cases/update-user.use-case.d.ts +0 -13
- package/dist/services/users/use-cases/update-user.use-case.js +0 -53
- package/dist/services/users/use-cases/update-user.use-case.mjs +0 -29
- package/dist/services/users/utils/default-model.d.ts +0 -6
- package/dist/services/users/utils/default-model.js +0 -38
- package/dist/services/users/utils/default-model.mjs +0 -14
- package/examples/authentication/login.ts +0 -22
- package/examples/users/create-user.ts +0 -25
- package/examples/users/delete-user.ts +0 -42
- package/examples/users/get-user-by-id.ts +0 -21
- package/examples/users/list-users.ts +0 -22
- package/examples/users/update-user.ts +0 -25
|
@@ -24,9 +24,8 @@ __export(automation_runner_exports, {
|
|
|
24
24
|
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
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var import_base = require("../../../common/base/index.js");
|
|
27
|
+
var import_common = require("nanosaas/common");
|
|
28
|
+
var import_users = require("nanosaas/users");
|
|
30
29
|
var import_agent = require("../../../harness/agent.js");
|
|
31
30
|
var import_loop = require("../../../loops/agi/loop.js");
|
|
32
31
|
var import_chats = require("../../chats/index.js");
|
|
@@ -51,7 +50,7 @@ class AutomationRunner {
|
|
|
51
50
|
}
|
|
52
51
|
options;
|
|
53
52
|
workerId;
|
|
54
|
-
logger = new
|
|
53
|
+
logger = new import_common.Logger();
|
|
55
54
|
inFlight = /* @__PURE__ */ new Set();
|
|
56
55
|
running = false;
|
|
57
56
|
timer;
|
|
@@ -84,7 +83,7 @@ class AutomationRunner {
|
|
|
84
83
|
await new import_sync_automation_runs.SyncAutomationRunsUseCase().execute({});
|
|
85
84
|
} catch (error) {
|
|
86
85
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] Failed to sync the open runs");
|
|
87
|
-
await (0,
|
|
86
|
+
await (0, import_common.reportError)(error, { source: "automations", stage: "sync" });
|
|
88
87
|
}
|
|
89
88
|
if (capacity <= 0) return;
|
|
90
89
|
const data = await new import_claim_due_automations.ClaimDueAutomationsUseCase().execute({ workerId: this.workerId, limit: capacity, leaseMs: this.options.leaseMs ?? (0, import_settings.leaseMs)() });
|
|
@@ -97,7 +96,7 @@ class AutomationRunner {
|
|
|
97
96
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
98
97
|
}
|
|
99
98
|
async runNow(params) {
|
|
100
|
-
const data = await new import_start_automation_run.StartAutomationRunUseCase().execute({ automationId: params.automationId,
|
|
99
|
+
const data = await new import_start_automation_run.StartAutomationRunUseCase().execute({ automationId: params.automationId, actor: params.actor, 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
|
}
|
|
@@ -105,7 +104,7 @@ class AutomationRunner {
|
|
|
105
104
|
while (this.running) {
|
|
106
105
|
this.ticking = this.tick().catch(async (error) => {
|
|
107
106
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] The worker failed to check the due automations");
|
|
108
|
-
await (0,
|
|
107
|
+
await (0, import_common.reportError)(error, { source: "automations", stage: "tick" });
|
|
109
108
|
});
|
|
110
109
|
await this.ticking;
|
|
111
110
|
if (!this.running) break;
|
|
@@ -139,7 +138,7 @@ class AutomationRunner {
|
|
|
139
138
|
} catch (failure) {
|
|
140
139
|
error = { code: failure?.code ?? "RUNNER_ERROR", message: failure?.message ?? String(failure) };
|
|
141
140
|
this.logger.error({ error: error.message, automationId, runId }, "[AUTOMATIONS] A run failed");
|
|
142
|
-
await (0,
|
|
141
|
+
await (0, import_common.reportError)(failure, { source: "automations", stage: "run", automationId, runId });
|
|
143
142
|
} finally {
|
|
144
143
|
clearInterval(heartbeat);
|
|
145
144
|
}
|
|
@@ -147,9 +146,11 @@ class AutomationRunner {
|
|
|
147
146
|
await this.notify({ automation, run: data ?? run, chat });
|
|
148
147
|
}
|
|
149
148
|
async runAgent(automation, run) {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
const owner = import_common.Actor.fromClaims({ userId: String(automation.ownerId) });
|
|
150
|
+
const profile = await (0, import_users.profileOf)(owner).catch(() => void 0);
|
|
151
|
+
if (!profile) return { status: "failed", error: { code: "OWNER_NOT_FOUND", message: "The owner of the automation does not exist" } };
|
|
152
|
+
const actor = owner.withProfile(profile);
|
|
153
|
+
const configured = typeof this.options.agent === "function" ? await this.options.agent({ automation, actor }) : this.options.agent ?? {};
|
|
153
154
|
const loop = configured.loop ?? new import_loop.AgiLoop();
|
|
154
155
|
const agent = new import_agent.Agent({ ...configured, loop });
|
|
155
156
|
const model = automation.modelProvider && automation.modelName ? { modelProvider: automation.modelProvider, modelName: automation.modelName } : {};
|
|
@@ -158,14 +159,14 @@ class AutomationRunner {
|
|
|
158
159
|
draft.settings?.setExecutionMode("autonomous");
|
|
159
160
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
160
161
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
161
|
-
const created = await (0, import_chats.createChat)({ payload: draft.toJSON(),
|
|
162
|
+
const created = await (0, import_chats.createChat)({ payload: draft.toJSON(), actor });
|
|
162
163
|
const chatId = String(created?._id);
|
|
163
164
|
await new import_attach_automation_run_chat.AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
164
165
|
const result = await agent.run({
|
|
165
166
|
input: { message: (0, import_event_message.buildMessage)(automation.instructions, run.payload), chatId },
|
|
166
167
|
options: { executionMode: "autonomous", ...model },
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
actor,
|
|
169
|
+
requestContext: import_common.RequestContext.fromJSON({ situation: { timezone: profile.preferences?.timezone?.ianaIdentifier } })
|
|
169
170
|
});
|
|
170
171
|
const chat = result.data;
|
|
171
172
|
const state = chat?.state;
|
|
@@ -182,7 +183,7 @@ class AutomationRunner {
|
|
|
182
183
|
await this.options.onRunFinished(event);
|
|
183
184
|
} catch (error) {
|
|
184
185
|
this.logger.error({ error: error?.message ?? error }, "[AUTOMATIONS] The onRunFinished callback failed");
|
|
185
|
-
await (0,
|
|
186
|
+
await (0, import_common.reportError)(error, { source: "automations", stage: "onRunFinished" });
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { hostname } from "node:os";
|
|
3
|
-
import { Logger } from "
|
|
4
|
-
import {
|
|
5
|
-
import { CurrentUser, CurrentSession } from "../../../common/base/index.js";
|
|
3
|
+
import { Logger, reportError, Actor, RequestContext } from "nanosaas/common";
|
|
4
|
+
import { profileOf } from "nanosaas/users";
|
|
6
5
|
import { Agent } from "../../../harness/agent.js";
|
|
7
6
|
import { AgiLoop } from "../../../loops/agi/loop.js";
|
|
8
7
|
import { createChat } from "../../chats/index.js";
|
|
@@ -73,7 +72,7 @@ class AutomationRunner {
|
|
|
73
72
|
for (const { automation, run } of queued.claimed) this.track(this.execute(automation, run));
|
|
74
73
|
}
|
|
75
74
|
async runNow(params) {
|
|
76
|
-
const data = await new StartAutomationRunUseCase().execute({ automationId: params.automationId,
|
|
75
|
+
const data = await new StartAutomationRunUseCase().execute({ automationId: params.automationId, actor: params.actor, scope: params.scope, workerId: this.workerId, leaseMs: this.options.leaseMs ?? defaultLeaseMs() });
|
|
77
76
|
this.track(this.execute(data.automation, data.run));
|
|
78
77
|
return { run: data.run };
|
|
79
78
|
}
|
|
@@ -123,9 +122,11 @@ class AutomationRunner {
|
|
|
123
122
|
await this.notify({ automation, run: data ?? run, chat });
|
|
124
123
|
}
|
|
125
124
|
async runAgent(automation, run) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
const owner = Actor.fromClaims({ userId: String(automation.ownerId) });
|
|
126
|
+
const profile = await profileOf(owner).catch(() => void 0);
|
|
127
|
+
if (!profile) return { status: "failed", error: { code: "OWNER_NOT_FOUND", message: "The owner of the automation does not exist" } };
|
|
128
|
+
const actor = owner.withProfile(profile);
|
|
129
|
+
const configured = typeof this.options.agent === "function" ? await this.options.agent({ automation, actor }) : this.options.agent ?? {};
|
|
129
130
|
const loop = configured.loop ?? new AgiLoop();
|
|
130
131
|
const agent = new Agent({ ...configured, loop });
|
|
131
132
|
const model = automation.modelProvider && automation.modelName ? { modelProvider: automation.modelProvider, modelName: automation.modelName } : {};
|
|
@@ -134,14 +135,14 @@ class AutomationRunner {
|
|
|
134
135
|
draft.settings?.setExecutionMode("autonomous");
|
|
135
136
|
if (model.modelProvider) draft.settings?.setModelProvider(model.modelProvider);
|
|
136
137
|
if (model.modelName) draft.settings?.setModelName(model.modelName);
|
|
137
|
-
const created = await createChat({ payload: draft.toJSON(),
|
|
138
|
+
const created = await createChat({ payload: draft.toJSON(), actor });
|
|
138
139
|
const chatId = String(created?._id);
|
|
139
140
|
await new AttachAutomationRunChatUseCase().execute({ runId: String(run._id), chatId });
|
|
140
141
|
const result = await agent.run({
|
|
141
142
|
input: { message: buildMessage(automation.instructions, run.payload), chatId },
|
|
142
143
|
options: { executionMode: "autonomous", ...model },
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
actor,
|
|
145
|
+
requestContext: RequestContext.fromJSON({ situation: { timezone: profile.preferences?.timezone?.ianaIdentifier } })
|
|
145
146
|
});
|
|
146
147
|
const chat = result.data;
|
|
147
148
|
const state = chat?.state;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,11 +21,11 @@ __export(attach_automation_run_chat_use_case_exports, {
|
|
|
21
21
|
AttachAutomationRunChatUseCase: () => AttachAutomationRunChatUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(attach_automation_run_chat_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_entities = require("../entities");
|
|
26
26
|
var import_repositories = require("../repositories");
|
|
27
27
|
var import_runner_scope = require("../utils/runner-scope");
|
|
28
|
-
class AttachAutomationRunChatUseCase extends
|
|
28
|
+
class AttachAutomationRunChatUseCase extends import_common.BaseUseCase {
|
|
29
29
|
constructor(automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRun } from "../entities";
|
|
3
3
|
import { AutomationRunRepository } from "../repositories";
|
|
4
4
|
import { runnerScope } from "../utils/runner-scope";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
@@ -21,8 +21,7 @@ __export(claim_due_automations_use_case_exports, {
|
|
|
21
21
|
ClaimDueAutomationsUseCase: () => ClaimDueAutomationsUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(claim_due_automations_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_base = require("../../../common/base/base.use-case.js");
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
26
25
|
var import_repositories = require("../repositories");
|
|
27
26
|
var import_next_run = require("../utils/next-run");
|
|
28
27
|
var import_open_run = require("../utils/open-run");
|
|
@@ -31,7 +30,7 @@ var import_previous_run = require("../utils/previous-run");
|
|
|
31
30
|
var import_sync_automation_run = require("./sync-automation-run.use-case");
|
|
32
31
|
var import_runner_scope = require("../utils/runner-scope");
|
|
33
32
|
const DEFAULT_LIMIT = 10;
|
|
34
|
-
class ClaimDueAutomationsUseCase extends
|
|
33
|
+
class ClaimDueAutomationsUseCase extends import_common.BaseUseCase {
|
|
35
34
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository(), syncRun = new import_sync_automation_run.SyncAutomationRunUseCase()) {
|
|
36
35
|
super();
|
|
37
36
|
this.automationRepository = automationRepository;
|
|
@@ -41,7 +40,7 @@ class ClaimDueAutomationsUseCase extends import_base.BaseUseCase {
|
|
|
41
40
|
automationRepository;
|
|
42
41
|
automationRunRepository;
|
|
43
42
|
syncRun;
|
|
44
|
-
log = new
|
|
43
|
+
log = new import_common.Logger();
|
|
45
44
|
async execute(params) {
|
|
46
45
|
const { workerId } = params;
|
|
47
46
|
if (!workerId) throw new Error("The id of the worker is required");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Logger } from "
|
|
2
|
-
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
1
|
+
import { Logger, BaseUseCase } from "nanosaas/common";
|
|
3
2
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
4
3
|
import { computeNextRun } from "../utils/next-run";
|
|
5
4
|
import { openRun } from "../utils/open-run";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
@@ -21,7 +21,7 @@ __export(claim_queued_automation_runs_use_case_exports, {
|
|
|
21
21
|
ClaimQueuedAutomationRunsUseCase: () => ClaimQueuedAutomationRunsUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(claim_queued_automation_runs_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_entities = require("../entities");
|
|
26
26
|
var import_repositories = require("../repositories");
|
|
27
27
|
var import_previous_run = require("../utils/previous-run");
|
|
@@ -29,7 +29,7 @@ var import_settings = require("../utils/settings");
|
|
|
29
29
|
var import_sync_automation_run = require("./sync-automation-run.use-case");
|
|
30
30
|
var import_runner_scope = require("../utils/runner-scope");
|
|
31
31
|
const SCAN_LIMIT = 200;
|
|
32
|
-
class ClaimQueuedAutomationRunsUseCase extends
|
|
32
|
+
class ClaimQueuedAutomationRunsUseCase extends import_common.BaseUseCase {
|
|
33
33
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository(), syncRun = new import_sync_automation_run.SyncAutomationRunUseCase()) {
|
|
34
34
|
super();
|
|
35
35
|
this.automationRepository = automationRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRun } from "../entities";
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
4
4
|
import { findPausedRun } from "../utils/previous-run";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationPayload, AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,20 +21,20 @@ __export(create_automation_use_case_exports, {
|
|
|
21
21
|
CreateAutomationUseCase: () => CreateAutomationUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(create_automation_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
26
|
var import_entities = require("../entities");
|
|
27
|
-
var
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
28
28
|
var import_automation_fields = require("../utils/automation-fields");
|
|
29
|
-
class CreateAutomationUseCase extends
|
|
30
|
-
constructor(automationRepository = new
|
|
29
|
+
class CreateAutomationUseCase extends import_common.BaseUseCase {
|
|
30
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
31
31
|
super();
|
|
32
32
|
this.automationRepository = automationRepository;
|
|
33
33
|
}
|
|
34
34
|
automationRepository;
|
|
35
35
|
async execute(params) {
|
|
36
|
-
const { payload,
|
|
37
|
-
if (!
|
|
36
|
+
const { payload, actor } = params;
|
|
37
|
+
if (!actor?.userId) throw new Error("actor is required to create an automation");
|
|
38
38
|
const fields = (0, import_automation_fields.readAutomationFields)(payload, { complete: true });
|
|
39
39
|
(0, import_automation_fields.assertModel)(fields.modelProvider, fields.modelName);
|
|
40
40
|
const automation = import_entities.Automation.fromJSON({
|
|
@@ -48,7 +48,7 @@ class CreateAutomationUseCase extends import_base.BaseUseCase {
|
|
|
48
48
|
automation.scheduleNextRun();
|
|
49
49
|
const schedule = automation.triggers?.schedule;
|
|
50
50
|
if (schedule?.enabled && !schedule.nextRunAt) throw new Error("The date of the recurrence has already passed");
|
|
51
|
-
await this.automationRepository.create(automation, params.scope ??
|
|
51
|
+
await this.automationRepository.create(automation, params.scope ?? import_db.Scope.canEdit(actor));
|
|
52
52
|
return automation.toJSON();
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
3
|
import { Automation } from "../entities";
|
|
4
4
|
import { AutomationRepository } from "../repositories";
|
|
5
5
|
import { readAutomationFields, assertModel } from "../utils/automation-fields";
|
|
@@ -10,8 +10,8 @@ class CreateAutomationUseCase extends BaseUseCase {
|
|
|
10
10
|
}
|
|
11
11
|
automationRepository;
|
|
12
12
|
async execute(params) {
|
|
13
|
-
const { payload,
|
|
14
|
-
if (!
|
|
13
|
+
const { payload, actor } = params;
|
|
14
|
+
if (!actor?.userId) throw new Error("actor is required to create an automation");
|
|
15
15
|
const fields = readAutomationFields(payload, { complete: true });
|
|
16
16
|
assertModel(fields.modelProvider, fields.modelName);
|
|
17
17
|
const automation = Automation.fromJSON({
|
|
@@ -25,7 +25,7 @@ class CreateAutomationUseCase extends BaseUseCase {
|
|
|
25
25
|
automation.scheduleNextRun();
|
|
26
26
|
const schedule = automation.triggers?.schedule;
|
|
27
27
|
if (schedule?.enabled && !schedule.nextRunAt) throw new Error("The date of the recurrence has already passed");
|
|
28
|
-
await this.automationRepository.create(automation, params.scope ?? Scope.canEdit(
|
|
28
|
+
await this.automationRepository.create(automation, params.scope ?? Scope.canEdit(actor));
|
|
29
29
|
return automation.toJSON();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,23 +21,23 @@ __export(delete_automation_use_case_exports, {
|
|
|
21
21
|
DeleteAutomationUseCase: () => DeleteAutomationUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(delete_automation_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
class DeleteAutomationUseCase extends
|
|
28
|
-
constructor(automationRepository = new
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_repositories = require("../repositories");
|
|
27
|
+
class DeleteAutomationUseCase extends import_common.BaseUseCase {
|
|
28
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
29
29
|
super();
|
|
30
30
|
this.automationRepository = automationRepository;
|
|
31
31
|
}
|
|
32
32
|
automationRepository;
|
|
33
33
|
async execute(params) {
|
|
34
|
-
const { id, hardDelete,
|
|
34
|
+
const { id, hardDelete, actor } = params;
|
|
35
35
|
if (!id) throw new Error("Missing id");
|
|
36
36
|
if (hardDelete) {
|
|
37
|
-
const result2 = await this.automationRepository.deleteById(id, params.scope ??
|
|
37
|
+
const result2 = await this.automationRepository.deleteById(id, params.scope ?? import_db.Scope.asAdmin(actor));
|
|
38
38
|
return { deletedCount: result2 };
|
|
39
39
|
}
|
|
40
|
-
const result = await this.automationRepository.softDeleteById(id, params.scope ??
|
|
40
|
+
const result = await this.automationRepository.softDeleteById(id, params.scope ?? import_db.Scope.canManage(actor));
|
|
41
41
|
if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
3
|
import { AutomationRepository } from "../repositories";
|
|
4
4
|
class DeleteAutomationUseCase extends BaseUseCase {
|
|
5
5
|
constructor(automationRepository = new AutomationRepository()) {
|
|
@@ -8,13 +8,13 @@ class DeleteAutomationUseCase extends BaseUseCase {
|
|
|
8
8
|
}
|
|
9
9
|
automationRepository;
|
|
10
10
|
async execute(params) {
|
|
11
|
-
const { id, hardDelete,
|
|
11
|
+
const { id, hardDelete, actor } = params;
|
|
12
12
|
if (!id) throw new Error("Missing id");
|
|
13
13
|
if (hardDelete) {
|
|
14
|
-
const result2 = await this.automationRepository.deleteById(id, params.scope ?? Scope.asAdmin(
|
|
14
|
+
const result2 = await this.automationRepository.deleteById(id, params.scope ?? Scope.asAdmin(actor));
|
|
15
15
|
return { deletedCount: result2 };
|
|
16
16
|
}
|
|
17
|
-
const result = await this.automationRepository.softDeleteById(id, params.scope ?? Scope.canManage(
|
|
17
|
+
const result = await this.automationRepository.softDeleteById(id, params.scope ?? Scope.canManage(actor));
|
|
18
18
|
if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
19
19
|
return result;
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRunError, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,11 +21,11 @@ __export(finish_automation_run_use_case_exports, {
|
|
|
21
21
|
FinishAutomationRunUseCase: () => FinishAutomationRunUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(finish_automation_run_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_entities = require("../entities");
|
|
26
26
|
var import_repositories = require("../repositories");
|
|
27
27
|
var import_runner_scope = require("../utils/runner-scope");
|
|
28
|
-
class FinishAutomationRunUseCase extends
|
|
28
|
+
class FinishAutomationRunUseCase extends import_common.BaseUseCase {
|
|
29
29
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRepository = automationRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRun } from "../entities";
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
4
4
|
import { runnerScope } from "../utils/runner-scope";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,18 +21,18 @@ __export(get_automation_by_id_use_case_exports, {
|
|
|
21
21
|
GetAutomationByIdUseCase: () => GetAutomationByIdUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_automation_by_id_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
class GetAutomationByIdUseCase extends
|
|
28
|
-
constructor(automationRepository = new
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_repositories = require("../repositories");
|
|
27
|
+
class GetAutomationByIdUseCase extends import_common.BaseUseCase {
|
|
28
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
29
29
|
super();
|
|
30
30
|
this.automationRepository = automationRepository;
|
|
31
31
|
}
|
|
32
32
|
automationRepository;
|
|
33
33
|
async execute(params) {
|
|
34
|
-
const { id,
|
|
35
|
-
const result = await this.automationRepository.findById(id, params.scope ??
|
|
34
|
+
const { id, actor } = params;
|
|
35
|
+
const result = await this.automationRepository.findById(id, params.scope ?? import_db.Scope.canView(actor));
|
|
36
36
|
return result ?? null;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
3
|
import { AutomationRepository } from "../repositories";
|
|
4
4
|
class GetAutomationByIdUseCase extends BaseUseCase {
|
|
5
5
|
constructor(automationRepository = new AutomationRepository()) {
|
|
@@ -8,8 +8,8 @@ class GetAutomationByIdUseCase extends BaseUseCase {
|
|
|
8
8
|
}
|
|
9
9
|
automationRepository;
|
|
10
10
|
async execute(params) {
|
|
11
|
-
const { id,
|
|
12
|
-
const result = await this.automationRepository.findById(id, params.scope ?? Scope.canView(
|
|
11
|
+
const { id, actor } = params;
|
|
12
|
+
const result = await this.automationRepository.findById(id, params.scope ?? Scope.canView(actor));
|
|
13
13
|
return result ?? null;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRepository } from '../repositories';
|
|
3
3
|
export interface Params extends BaseUseCaseParams {
|
|
4
4
|
id: string;
|
|
@@ -21,19 +21,19 @@ __export(issue_automation_event_token_use_case_exports, {
|
|
|
21
21
|
IssueAutomationEventTokenUseCase: () => IssueAutomationEventTokenUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(issue_automation_event_token_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_repositories = require("../repositories");
|
|
27
27
|
var import_event_token = require("../utils/event-token");
|
|
28
|
-
class IssueAutomationEventTokenUseCase extends
|
|
29
|
-
constructor(automationRepository = new
|
|
28
|
+
class IssueAutomationEventTokenUseCase extends import_common.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRepository = automationRepository;
|
|
32
32
|
}
|
|
33
33
|
automationRepository;
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { id, expiresIn,
|
|
36
|
-
const automation = await this.automationRepository.findById(id, params.scope ??
|
|
35
|
+
const { id, expiresIn, actor } = params;
|
|
36
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? import_db.Scope.canManage(actor));
|
|
37
37
|
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
38
38
|
if (!automation.triggers?.event) throw new Error("Only an automation with an event trigger has a token");
|
|
39
39
|
return (0, import_event_token.signEventToken)({ automationId: id, tokenVersion: automation.eventTokenVersion, expiresIn });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
3
|
import { AutomationRepository } from "../repositories";
|
|
4
4
|
import { signEventToken } from "../utils/event-token";
|
|
5
5
|
class IssueAutomationEventTokenUseCase extends BaseUseCase {
|
|
@@ -9,8 +9,8 @@ class IssueAutomationEventTokenUseCase extends BaseUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
automationRepository;
|
|
11
11
|
async execute(params) {
|
|
12
|
-
const { id, expiresIn,
|
|
13
|
-
const automation = await this.automationRepository.findById(id, params.scope ?? Scope.canManage(
|
|
12
|
+
const { id, expiresIn, actor } = params;
|
|
13
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? Scope.canManage(actor));
|
|
14
14
|
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
15
15
|
if (!automation.triggers?.event) throw new Error("Only an automation with an event trigger has a token");
|
|
16
16
|
return signEventToken({ automationId: id, tokenVersion: automation.eventTokenVersion, expiresIn });
|
package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryOptions } from '
|
|
2
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { QueryOptions } from 'nanosaas/db';
|
|
2
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
3
3
|
import { AutomationRunProps, AutomationRunStatus } from '../entities';
|
|
4
4
|
import { AutomationRunRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -22,21 +22,21 @@ __export(list_automation_runs_by_automation_use_case_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(list_automation_runs_by_automation_use_case_exports);
|
|
24
24
|
var import_mongodb = require("mongodb");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
class ListAutomationRunsByAutomationUseCase extends
|
|
29
|
-
constructor(automationRunRepository = new
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_common = require("nanosaas/common");
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
28
|
+
class ListAutomationRunsByAutomationUseCase extends import_common.BaseUseCase {
|
|
29
|
+
constructor(automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRunRepository = automationRunRepository;
|
|
32
32
|
}
|
|
33
33
|
automationRunRepository;
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { automationId, status, options,
|
|
35
|
+
const { automationId, status, options, actor } = params;
|
|
36
36
|
if (!automationId) throw new Error("Missing automationId");
|
|
37
37
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
38
38
|
const result = await this.automationRunRepository._.findManyPaginated({
|
|
39
|
-
scope: params.scope ??
|
|
39
|
+
scope: params.scope ?? import_db.Scope.canView(actor),
|
|
40
40
|
where: { automationId: new import_mongodb.ObjectId(automationId), ...status ? { status } : {} },
|
|
41
41
|
options: { page, limit, sortBy }
|
|
42
42
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectId } from "mongodb";
|
|
2
|
-
import { Scope } from "
|
|
3
|
-
import { BaseUseCase } from "
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
4
4
|
import { AutomationRunRepository } from "../repositories";
|
|
5
5
|
class ListAutomationRunsByAutomationUseCase extends BaseUseCase {
|
|
6
6
|
constructor(automationRunRepository = new AutomationRunRepository()) {
|
|
@@ -9,11 +9,11 @@ class ListAutomationRunsByAutomationUseCase extends BaseUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
automationRunRepository;
|
|
11
11
|
async execute(params) {
|
|
12
|
-
const { automationId, status, options,
|
|
12
|
+
const { automationId, status, options, actor } = params;
|
|
13
13
|
if (!automationId) throw new Error("Missing automationId");
|
|
14
14
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
15
15
|
const result = await this.automationRunRepository._.findManyPaginated({
|
|
16
|
-
scope: params.scope ?? Scope.canView(
|
|
16
|
+
scope: params.scope ?? Scope.canView(actor),
|
|
17
17
|
where: { automationId: new ObjectId(automationId), ...status ? { status } : {} },
|
|
18
18
|
options: { page, limit, sortBy }
|
|
19
19
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryOptions } from '
|
|
2
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { QueryOptions } from 'nanosaas/db';
|
|
2
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
3
3
|
import { AutomationRunProps, AutomationRunStatus } from '../entities';
|
|
4
4
|
import { AutomationRunRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|