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
package/docs/automations.md
CHANGED
|
@@ -38,7 +38,7 @@ const result = await createAutomation({
|
|
|
38
38
|
modelProvider: 'anthropic',
|
|
39
39
|
modelName: 'claude-haiku-5-5',
|
|
40
40
|
},
|
|
41
|
-
|
|
41
|
+
actor,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
result.triggers.schedule.nextRunAt
|
|
@@ -72,7 +72,7 @@ await createAutomation({
|
|
|
72
72
|
event: {},
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
-
|
|
75
|
+
actor,
|
|
76
76
|
})
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -117,19 +117,19 @@ It returns the next dates (at most 20) without saving anything, so a screen can
|
|
|
117
117
|
## Managing automations
|
|
118
118
|
|
|
119
119
|
```typescript
|
|
120
|
-
await updateAutomation({ id, payload: { triggers: { schedule: { enabled: false } } },
|
|
120
|
+
await updateAutomation({ id, payload: { triggers: { schedule: { enabled: false } } }, actor })
|
|
121
121
|
|
|
122
|
-
await updateAutomation({ id, payload: { triggers: { event: { enabled: true } } },
|
|
122
|
+
await updateAutomation({ id, payload: { triggers: { event: { enabled: true } } }, actor })
|
|
123
123
|
|
|
124
|
-
await updateAutomation({ id, payload: { triggers: { event: {} } },
|
|
124
|
+
await updateAutomation({ id, payload: { triggers: { event: {} } }, actor })
|
|
125
125
|
|
|
126
|
-
await updateAutomation({ id, payload: { triggers: { event: null } },
|
|
126
|
+
await updateAutomation({ id, payload: { triggers: { event: null } }, actor })
|
|
127
127
|
|
|
128
|
-
const automation = await getAutomationById({ id,
|
|
128
|
+
const automation = await getAutomationById({ id, actor })
|
|
129
129
|
|
|
130
|
-
const automations = await listAutomationsByUser({ options: { page: 1, limit: 10 },
|
|
130
|
+
const automations = await listAutomationsByUser({ options: { page: 1, limit: 10 }, actor })
|
|
131
131
|
|
|
132
|
-
await deleteAutomation({ id,
|
|
132
|
+
await deleteAutomation({ id, actor })
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
- **The triggers are merged key by key.** Send only the trigger that changes, and inside it only the fields that change. What you do not send is kept. To pause the whole automation, turn off both triggers.
|
|
@@ -153,10 +153,10 @@ const automation = await createAutomation({
|
|
|
153
153
|
instructions: 'Find the cause of the cost alert in AWS and send a summary to the channel #costs',
|
|
154
154
|
triggers: { event: {} },
|
|
155
155
|
},
|
|
156
|
-
|
|
156
|
+
actor,
|
|
157
157
|
})
|
|
158
158
|
|
|
159
|
-
const data = await issueAutomationEventToken({ id: String(automation._id), expiresIn: '90d',
|
|
159
|
+
const data = await issueAutomationEventToken({ id: String(automation._id), expiresIn: '90d', actor })
|
|
160
160
|
|
|
161
161
|
data.token
|
|
162
162
|
data.expiresAt
|
|
@@ -217,7 +217,7 @@ The token is a JWT signed with `JWT_SECRET`. It is not stored: the owner can ask
|
|
|
217
217
|
|
|
218
218
|
| Claim | Value |
|
|
219
219
|
| --- | --- |
|
|
220
|
-
| `iss` | `openloops
|
|
220
|
+
| `iss` | The issuer of your solution (`openloops` with `appName: 'openloops'`), like every token of the package (see [authentication](authentication.md#the-tokens)). |
|
|
221
221
|
| `aud` | `automation-event`. A session token of a user is refused, and this one does not log anybody in. |
|
|
222
222
|
| `sub` | The id of the automation. It must be the one of the URL. |
|
|
223
223
|
| `v` | The `eventTokenVersion` of the automation when the token was issued. |
|
|
@@ -228,17 +228,17 @@ The `eventTokenVersion` is a field of the automation, not of the event trigger,
|
|
|
228
228
|
|
|
229
229
|
| Operation | What it does | Changes `eventTokenVersion` | Effect on the tokens already issued |
|
|
230
230
|
| --- | --- | --- | --- |
|
|
231
|
-
| `issueAutomationEventToken({ id, expiresIn?,
|
|
232
|
-
| `revokeAutomationEventToken({ id, token,
|
|
233
|
-
| `rotateAutomationEventTokens({ id,
|
|
231
|
+
| `issueAutomationEventToken({ id, expiresIn?, actor })` | Signs a new token with the current `eventTokenVersion` and a new `jti`. It does not store it and it does not write the automation. | No | None. Every token issued before keeps working, so you can have one per system that sends events. |
|
|
232
|
+
| `revokeAutomationEventToken({ id, token, actor })` | Saves the `jti` of the token you pass in `revoked_tokens`. | No | Only that token stops working. The rest are valid. |
|
|
233
|
+
| `rotateAutomationEventTokens({ id, actor })` | Adds 1 to `eventTokenVersion` and saves the automation. It does not return a token. | Yes | Every token issued before stops working, because its `v` is not the current version any more. Issue a new one afterwards. |
|
|
234
234
|
|
|
235
235
|
So issuing again does **not** replace the previous token. To "regenerate" a token and kill the old ones, rotate first and then issue. The three are only for the owner of the automation or an admin, and the event trigger must exist: without it they fail with an error.
|
|
236
236
|
|
|
237
237
|
Four ways to take a token out of use:
|
|
238
238
|
|
|
239
239
|
- **Let it expire,** if it was issued with `expiresIn`. A token that expires stops working without notice, and the refused events create no run, so watch the `expired` reasons in your logs.
|
|
240
|
-
- **Revoke one token.** If a token leaked, pass it to `revokeAutomationEventToken({ id, token,
|
|
241
|
-
- **Rotate.** `rotateAutomationEventTokens({ id,
|
|
240
|
+
- **Revoke one token.** If a token leaked, pass it to `revokeAutomationEventToken({ id, token, actor })`. Its `jti` goes to the collection `revoked_tokens` and only that token stops working. The entry is deleted by itself when the token would have expired. The tokens are not stored, so there is no list to choose from: you need the leaked token in your hands.
|
|
241
|
+
- **Rotate.** `rotateAutomationEventTokens({ id, actor })` increases the version and **every** token issued before stops working. Use it when you do not have the leaked token, or you want to start again. Issue the new token afterwards.
|
|
242
242
|
- **Turn the event trigger off.** Its events are refused with the reason `disabled`, and the tokens work again when it is turned on. If you remove the event trigger instead, the tokens are refused with the reason `invalid` until an event is added again, see [managing automations](#managing-automations).
|
|
243
243
|
|
|
244
244
|
A revoked token is checked after its signature, so an invalid token never reaches the database.
|
|
@@ -248,9 +248,9 @@ A revoked token is checked after its signature, so an invalid token never reache
|
|
|
248
248
|
Every execution is a run.
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
|
-
const byAutomation = await listAutomationRunsByAutomation({ automationId, status: 'paused', options: { page: 1, limit: 20 },
|
|
251
|
+
const byAutomation = await listAutomationRunsByAutomation({ automationId, status: 'paused', options: { page: 1, limit: 20 }, actor })
|
|
252
252
|
|
|
253
|
-
const byUser = await listAutomationRunsByUser({ status: 'failed',
|
|
253
|
+
const byUser = await listAutomationRunsByUser({ status: 'failed', actor })
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
| Field | Meaning |
|
|
@@ -301,9 +301,11 @@ process.on('SIGTERM', async () => {
|
|
|
301
301
|
})
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
+
The runner does not share anything with the agent you build for your chat. If you leave out `agent`, every run starts with an agent that has no tools, no guards and no MCP servers, and nothing warns you: the model just answers that it cannot do the task. Pass the same tools and options you give your chat agent. The best way is to build them in one place, for example a function `buildAgentOptions()`, and call it from your chat endpoint and from the `agent` option of the runner. Two copies of the configuration drift apart, and the automations are the ones that fail, with no one watching.
|
|
305
|
+
|
|
304
306
|
| Option | Default | What it does |
|
|
305
307
|
| --- | --- | --- |
|
|
306
|
-
| `agent` | `{}` | The options of the `Agent` used for every run: tools, guards, `maxIterations`, `strictMode`, `identity`... It can be a function `({ automation,
|
|
308
|
+
| `agent` | `{}` (no tools, no guards) | The options of the `Agent` used for every run: tools, guards, `maxIterations`, `strictMode`, `identity`... It can be a function `({ automation, actor }) => options` when they depend on the automation or on the user. The loop is `AgiLoop` unless you set `loop`. A custom loop must support autonomous mode (`harness.executionMode`). |
|
|
307
309
|
| `intervalMs` | `60000` | How often it checks. Also set with `AUTOMATIONS_POLL_INTERVAL_MS`. `runner.wake()` makes it check now. |
|
|
308
310
|
| `leaseMs` | `600000` | How long an automation stays locked while it runs, renewed while the run lasts. Also set with `AUTOMATIONS_LEASE_MS`. |
|
|
309
311
|
| `maxConcurrentRuns` | `3` | How many runs a runner executes at once. |
|
|
@@ -351,10 +353,10 @@ const runner = createAutomationRunner({
|
|
|
351
353
|
### Running by hand
|
|
352
354
|
|
|
353
355
|
```typescript
|
|
354
|
-
const { run } = await runner.runNow({ automationId,
|
|
356
|
+
const { run } = await runner.runNow({ automationId, actor })
|
|
355
357
|
```
|
|
356
358
|
|
|
357
|
-
It starts the run at once, only if the automation is of `
|
|
359
|
+
It starts the run at once, only if the automation is of `actor`, and returns while it keeps running in the background. It does not change the next scheduled run. It is refused if the automation is already running. Any process that has a runner can call it, it does not need to be the one that called `start()`.
|
|
358
360
|
|
|
359
361
|
### Several instances
|
|
360
362
|
|
|
@@ -407,7 +409,7 @@ Before 0.4.0 this module was called `agentic-jobs`. The old names are not kept a
|
|
|
407
409
|
recurrence: { type: 'daily', time: '08:00' },
|
|
408
410
|
timezone: 'America/New_York',
|
|
409
411
|
},
|
|
410
|
-
|
|
412
|
+
actor,
|
|
411
413
|
})
|
|
412
414
|
```
|
|
413
415
|
|
|
@@ -425,7 +427,7 @@ Before 0.4.0 this module was called `agentic-jobs`. The old names are not kept a
|
|
|
425
427
|
},
|
|
426
428
|
},
|
|
427
429
|
},
|
|
428
|
-
|
|
430
|
+
actor,
|
|
429
431
|
})
|
|
430
432
|
```
|
|
431
433
|
|
|
@@ -458,10 +460,10 @@ Version 0.5.0 lets an automation have a schedule and an event at the same time.
|
|
|
458
460
|
enabled: true,
|
|
459
461
|
trigger: { type: 'schedule', recurrence: { type: 'daily', time: '08:00' }, timezone: 'America/New_York' },
|
|
460
462
|
},
|
|
461
|
-
|
|
463
|
+
actor,
|
|
462
464
|
})
|
|
463
465
|
|
|
464
|
-
await createAutomation({ payload: { name: 'Alarms', instructions: 'Analyze the alarm', trigger: { type: 'event' } },
|
|
466
|
+
await createAutomation({ payload: { name: 'Alarms', instructions: 'Analyze the alarm', trigger: { type: 'event' } }, actor })
|
|
465
467
|
```
|
|
466
468
|
|
|
467
469
|
Now:
|
|
@@ -473,10 +475,10 @@ Version 0.5.0 lets an automation have a schedule and an event at the same time.
|
|
|
473
475
|
instructions: 'Summarize my open tickets',
|
|
474
476
|
triggers: { schedule: { enabled: true, recurrence: { type: 'daily', time: '08:00' }, timezone: 'America/New_York' } },
|
|
475
477
|
},
|
|
476
|
-
|
|
478
|
+
actor,
|
|
477
479
|
})
|
|
478
480
|
|
|
479
|
-
await createAutomation({ payload: { name: 'Alarms', instructions: 'Analyze the alarm', triggers: { event: {} } },
|
|
481
|
+
await createAutomation({ payload: { name: 'Alarms', instructions: 'Analyze the alarm', triggers: { event: {} } }, actor })
|
|
480
482
|
```
|
|
481
483
|
|
|
482
484
|
Sending `trigger` or `enabled` in the payload of `createAutomation` or `updateAutomation` fails with an error that says where the field went, so nothing is ignored silently.
|
package/docs/chats.md
CHANGED
|
@@ -34,28 +34,28 @@ Messages with `excludeFromContext` are shown in the history but never sent to th
|
|
|
34
34
|
```typescript
|
|
35
35
|
const result = await listChatsByUser({
|
|
36
36
|
options: { page: 1, limit: 10 },
|
|
37
|
-
|
|
37
|
+
actor,
|
|
38
38
|
})
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Sorted by last update, newest first. Defaults to page 1 and 10 chats. The result has `items` and `hasMore`, which is `true` when there is a next page.
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
|
-
const autonomous = await listChatsByUser({ executionMode: 'autonomous',
|
|
44
|
+
const autonomous = await listChatsByUser({ executionMode: 'autonomous', actor })
|
|
45
45
|
|
|
46
|
-
const interactive = await listChatsByUser({ executionMode: 'interactive',
|
|
46
|
+
const interactive = await listChatsByUser({ executionMode: 'interactive', actor })
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
`executionMode` is optional. `autonomous` returns the chats that were created by an autonomous run and `interactive` returns the rest, including the chats saved before the mode existed. Combine it with `state.status` to show the autonomous runs that need attention: `awaiting_user_confirmation` or `awaiting_user_input` mean the run is paused until the user answers in the chat, and `failed` means it failed.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
const found = await listChatsByUser({ search: 'netflix',
|
|
52
|
+
const found = await listChatsByUser({ search: 'netflix', actor })
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
`search` is optional. It returns the chats whose title or at least one message contains the text, ignoring case, in the same order and with the same pagination. The text is matched literally, so characters such as `(` or `.` have no special meaning. It reads the messages without an index, which is fine for the chats of one user. An empty text is ignored.
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
const history = await listChatsByUser({ search: 'netflix', select: { title: 1, updatedAt: 1 },
|
|
58
|
+
const history = await listChatsByUser({ search: 'netflix', select: { title: 1, updatedAt: 1 }, actor })
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
`select` is optional and limits the fields that come back, as in `getChatById`. Without it every chat comes complete, with all its messages. A history list only needs a few fields, and `_id` always comes. `search` does not depend on `select`: it still looks in the messages when they are not returned, and the chat that the user picks is loaded with `getChatById`. A history without messages cannot show the first message of a chat that has no title, so [migrate the old chats](#migrating-to-080).
|
|
@@ -65,9 +65,9 @@ const history = await listChatsByUser({ search: 'netflix', select: { title: 1, u
|
|
|
65
65
|
In an interactive run the first node, `fast_responder`, writes a title for a chat that has none: at most 50 characters, in the language of the first message. The loop saves it on one line, without tags and cut to 80 characters, and never replaces a title that already exists. If the model returns nothing usable the chat stays without a title and the next message asks again. An autonomous run skips that node, so set the title yourself when you create its chat if you want one.
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
|
-
await updateChat({ id: chatId, payload: { title: 'Trip to Lisbon' },
|
|
68
|
+
await updateChat({ id: chatId, payload: { title: 'Trip to Lisbon' }, actor })
|
|
69
69
|
|
|
70
|
-
await updateChat({ id: chatId, payload: { settings: { notifyOnCompletion: true } }, unset: { title: '' },
|
|
70
|
+
await updateChat({ id: chatId, payload: { settings: { notifyOnCompletion: true } }, unset: { title: '' }, actor })
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
The first call renames the chat, and the agent keeps that title from then on. The second removes the title, so the next message gets a new one.
|
|
@@ -95,9 +95,9 @@ The changelog also lists two smaller changes of this version: `sanitizeString` n
|
|
|
95
95
|
## Getting one chat
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
|
-
const result = await getChatById({ id: chatId,
|
|
98
|
+
const result = await getChatById({ id: chatId, actor })
|
|
99
99
|
|
|
100
|
-
const state = await getChatById({ id: chatId, select: { state: 1 },
|
|
100
|
+
const state = await getChatById({ id: chatId, select: { state: 1 }, actor })
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
`select` limits the fields that come back, which is handy for polling the status of a long run.
|
|
@@ -105,9 +105,9 @@ const state = await getChatById({ id: chatId, select: { state: 1 }, currentUser
|
|
|
105
105
|
## Creating and updating
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
|
-
const created = await createChat({ payload: { settings: { loopName: 'agi' } },
|
|
108
|
+
const created = await createChat({ payload: { settings: { loopName: 'agi' } }, actor })
|
|
109
109
|
|
|
110
|
-
await updateChat({ id: chatId, payload: { settings: { modelProvider: 'anthropic', modelName: 'claude-haiku-5-5' } },
|
|
110
|
+
await updateChat({ id: chatId, payload: { settings: { modelProvider: 'anthropic', modelName: 'claude-haiku-5-5' } }, actor })
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
You rarely need `createChat`: `agent.run` creates the chat when you omit `chatId`.
|
|
@@ -115,9 +115,9 @@ You rarely need `createChat`: `agent.run` creates the chat when you omit `chatId
|
|
|
115
115
|
## Deleting a chat
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
|
-
await deleteChat({ id: chatId,
|
|
118
|
+
await deleteChat({ id: chatId, actor })
|
|
119
119
|
|
|
120
|
-
await deleteChat({ id: chatId, hardDelete: true,
|
|
120
|
+
await deleteChat({ id: chatId, hardDelete: true, actor })
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
The first one is a soft delete. A hard delete is for admins only.
|
|
@@ -127,7 +127,7 @@ The first one is a soft delete. A hard delete is for admins only.
|
|
|
127
127
|
```typescript
|
|
128
128
|
import { Agent } from 'openloops/core'
|
|
129
129
|
|
|
130
|
-
await Agent.interruptExecution(chatId,
|
|
130
|
+
await Agent.interruptExecution(chatId, actor)
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
See [agent](agent.md#stopping-a-running-turn).
|
package/docs/configuration.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# Configuration
|
|
2
2
|
|
|
3
|
-
`openloops` reads its configuration from environment variables. Copy `.env.example` and fill in what you use.
|
|
3
|
+
`openloops` reads its configuration from environment variables, through `nanosaas`. Call `configure({ appName: 'openloops' })` once when your process starts (the package never calls it for you): `appName` gives the prefix of the variables below (`OPENLOOPS_`), the default database and the issuer of the tokens. Nothing loads `.env` for you. Copy `.env.example` and fill in what you use.
|
|
4
4
|
|
|
5
5
|
| Variable | Required | What it is for |
|
|
6
6
|
| --- | --- | --- |
|
|
7
7
|
| `OPENLOOPS_DB_URI` | yes | MongoDB connection string. |
|
|
8
8
|
| `OPENLOOPS_DB_NAME` | no | Database name. Defaults to `openloops`. |
|
|
9
9
|
| `OPENLOOPS_MONGO_MAX_POOL_SIZE` | no | Most connections each process keeps open to MongoDB. Defaults to `3`, which suits serverless functions, where every instance handles one request at a time. Raise it for a long-running server. |
|
|
10
|
-
| `
|
|
11
|
-
| `SECRET_MANAGER_KEY_V<N>` | only if you use `ENC:v<N>:` values | Key of version `N` of the [versioned encrypted values](#encrypted-values). |
|
|
10
|
+
| `OPENLOOPS_ENCRYPTION_KEY_V<N>` | only if you use `ENC:v2:` values | Master key of version `N` of the [encrypted values](#encrypted-values), random and 32 characters or more. |
|
|
12
11
|
| `ANTHROPIC_API_KEY` | for the default model | API key of the default provider, `anthropic`. |
|
|
13
12
|
| `OPENAI_API_KEY`, `GEMINI_API_KEY` | for those providers | API keys of the other providers you choose per chat. |
|
|
14
13
|
| `JWT_SECRET` | for `login` and for event automations | Secret that signs the tokens of the sessions, of the reset of a password and of [event automations](automations.md#the-token). See [authentication](authentication.md). |
|
|
@@ -26,33 +25,33 @@
|
|
|
26
25
|
|
|
27
26
|
## Encrypted values
|
|
28
27
|
|
|
29
|
-
Any value can be stored encrypted
|
|
30
|
-
|
|
31
|
-
- `ENC:<payload>` is decrypted with `SECRET_MANAGER_KEY`.
|
|
32
|
-
- `ENC:v<N>:<payload>` is decrypted with `SECRET_MANAGER_KEY_V<N>`. Versions let you rotate the key: encrypt new values with the next version, keep the old key until nothing uses it, then remove it.
|
|
28
|
+
Any value can be stored encrypted, as `ENC:v2:<key id>:<data>`. It is decrypted when it is read, with the master key named by its key id (`OPENLOOPS_ENCRYPTION_KEY_V<N>`), and only where it was made: the name of the variable and, in a multi tenant runtime, the id of the tenant are part of what authenticates it. Rotate a key by encrypting new values with the next version and keeping the old key until nothing uses it.
|
|
33
29
|
|
|
34
30
|
```ts
|
|
35
|
-
import {
|
|
31
|
+
import { encryptConfigValue, generateEncryptionKey } from 'nanosaas/common'
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
generateEncryptionKey()
|
|
34
|
+
encryptConfigValue('ANTHROPIC_API_KEY', 'sk-ant-...')
|
|
35
|
+
encryptConfigValue('ANTHROPIC_API_KEY', 'sk-ant-...', { tenantId: String(agent._id) })
|
|
39
36
|
```
|
|
40
37
|
|
|
38
|
+
The earlier format (`ENC:` and `ENC:v1:`) is not read. Migrate once with `reencrypt` of `nanosaas/common`, giving it the function that decrypts the old values. See the documentation of `nanosaas` about encryption.
|
|
39
|
+
|
|
41
40
|
## One process, several agents
|
|
42
41
|
|
|
43
42
|
By default the configuration is read from the environment, which is one configuration per process. To serve several agents from the same process, for example one function that runs every agent of a platform, run each request with its own configuration:
|
|
44
43
|
|
|
45
44
|
```ts
|
|
46
|
-
import {
|
|
45
|
+
import { runWithTenant } from 'nanosaas/common'
|
|
47
46
|
|
|
48
|
-
await
|
|
47
|
+
await runWithTenant(String(agent._id), configsOfThisAgent, () => handleRequest(event))
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
`configsOfThisAgent` is an object with the same names as the variables of this page (`OPENLOOPS_DB_URI`, `OPENLOOPS_DB_NAME`, `JWT_SECRET`, `ANTHROPIC_API_KEY`...), and its values can be encrypted. Everything that runs inside the callback, including what it awaits, reads those values and never the environment, so a name that is missing from the object is empty and does not fall back to the environment. Outside of `
|
|
50
|
+
`configsOfThisAgent` is an object with the same names as the variables of this page (`OPENLOOPS_DB_URI`, `OPENLOOPS_DB_NAME`, `JWT_SECRET`, `ANTHROPIC_API_KEY`...), and its values can be encrypted. Everything that runs inside the callback, including what it awaits, reads those values and never the environment, so a name that is missing from the object is empty and does not fall back to the environment. Outside of `runWithTenant` nothing changes.
|
|
52
51
|
|
|
53
52
|
Each agent can use its own database, even in its own cluster: the repositories resolve the database name and the connection on every call, and the connections are shared by connection string. The API key of the provider is sent with each model call, so two agents never use each other's key. See the example [run-agent-multi-tenant](../examples/run-agent/run-agent-multi-tenant.ts).
|
|
54
53
|
|
|
55
|
-
Pass the configuration of a request to `
|
|
54
|
+
Pass the configuration of a request to `runWithTenant` before creating the `Agent` and before resolving the user, and do not keep the result of `secretManager.get` between requests.
|
|
56
55
|
|
|
57
56
|
## Which model a chat uses
|
|
58
57
|
|
|
@@ -100,7 +99,7 @@ Choose the model of a chat when you run it:
|
|
|
100
99
|
await agent.run({
|
|
101
100
|
input: { message: 'hi' },
|
|
102
101
|
options: { modelProvider: 'anthropic', modelName: 'claude-haiku-5-5' },
|
|
103
|
-
|
|
102
|
+
actor,
|
|
104
103
|
})
|
|
105
104
|
```
|
|
106
105
|
|
package/docs/error-reporting.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
19
|
import * as Sentry from '@sentry/node'
|
|
20
|
-
import { setErrorReporter } from '
|
|
20
|
+
import { setErrorReporter } from 'nanosaas/common'
|
|
21
21
|
|
|
22
22
|
Sentry.init({ dsn: process.env.MY_SENTRY_DSN })
|
|
23
23
|
|
|
@@ -49,7 +49,7 @@ import { AgiLoop } from 'openloops/loops'
|
|
|
49
49
|
|
|
50
50
|
const agent = new Agent({ loop: new AgiLoop() })
|
|
51
51
|
|
|
52
|
-
const result = await agent.run({ input: { message: 'hi, how are you?' },
|
|
52
|
+
const result = await agent.run({ input: { message: 'hi, how are you?' }, actor })
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
The first line is the file that declares the reporter. If this run fails, the reporter is called without anything else in this code. The [example](../examples/errors/error-reporting.ts) has the declaration at the top and the code that runs below it, in one file.
|
|
@@ -111,7 +111,7 @@ What is not reported are the errors that the use cases throw, such as a missing
|
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
113
|
try {
|
|
114
|
-
await updateChat({ id, payload: { title },
|
|
114
|
+
await updateChat({ id, payload: { title }, actor })
|
|
115
115
|
} catch (error) {
|
|
116
116
|
res.status(error.statusCode ?? 500).json({ message: error.errorMessage })
|
|
117
117
|
}
|
|
@@ -154,7 +154,7 @@ The simple way is a file of its own that declares the reporter, `error-reporting
|
|
|
154
154
|
|
|
155
155
|
```typescript
|
|
156
156
|
import * as Sentry from '@sentry/node'
|
|
157
|
-
import { setErrorReporter } from '
|
|
157
|
+
import { setErrorReporter } from 'nanosaas/common'
|
|
158
158
|
|
|
159
159
|
Sentry.init({ dsn: process.env.MY_SENTRY_DSN })
|
|
160
160
|
|
|
@@ -176,7 +176,7 @@ import './error-reporting-lambda'
|
|
|
176
176
|
import { listChatsByUser } from 'openloops/chats'
|
|
177
177
|
|
|
178
178
|
export const handler = async (event: any) => {
|
|
179
|
-
const result = await listChatsByUser({ options: { page: 1, limit: 10 },
|
|
179
|
+
const result = await listChatsByUser({ options: { page: 1, limit: 10 }, actor })
|
|
180
180
|
|
|
181
181
|
return { statusCode: 200, body: JSON.stringify(result) }
|
|
182
182
|
}
|
|
@@ -197,7 +197,7 @@ beforeEach(() => setErrorReporter(reporter))
|
|
|
197
197
|
afterEach(() => setErrorReporter(undefined))
|
|
198
198
|
|
|
199
199
|
it('reports a failed run', async () => {
|
|
200
|
-
await agent.run({ input: { message: 'hi' },
|
|
200
|
+
await agent.run({ input: { message: 'hi' }, actor })
|
|
201
201
|
|
|
202
202
|
expect(reporter).toHaveBeenCalledWith(expect.any(Error), expect.objectContaining({ source: 'agent' }))
|
|
203
203
|
})
|
package/docs/guardrails.md
CHANGED
|
@@ -57,7 +57,7 @@ const noSpam = new Guard({
|
|
|
57
57
|
| `type` | Where it runs. Only `'input'` exists: it runs on the user message before the model. |
|
|
58
58
|
| `reply` | What the user receives when the guard blocks. |
|
|
59
59
|
| `ref` | Reference shown to the user and written to the traces. Derived from `name` when omitted. |
|
|
60
|
-
| `handler` | Receives `{ message, chat,
|
|
60
|
+
| `handler` | Receives `{ message, chat, actor, requestContext, skillParams, logger }` and returns `{ passed, reason? }`. May be async. |
|
|
61
61
|
|
|
62
62
|
## What happens when a guard blocks
|
|
63
63
|
|
|
@@ -6,7 +6,7 @@ This page is for whoever builds the backend that uses `openloops`, a person or a
|
|
|
6
6
|
|
|
7
7
|
`openloops` is a harness for agents, and it gives you a set of use cases that read and write MongoDB. It does **not** include an HTTP server, routes, controllers, sessions or authorization. Your backend owns those, and calls `openloops` from its own handlers.
|
|
8
8
|
|
|
9
|
-
Requirements: Node 22 or newer and a MongoDB database. Install it with `npm install openloops` or `yarn add openloops
|
|
9
|
+
Requirements: Node 22 or newer and a MongoDB database. Install it with `npm install openloops nanosaas` or `yarn add openloops nanosaas` (`nanosaas` is a peer dependency, at the exact version that `openloops` asks for), call `configure({ appName: 'openloops' })` once when your process starts, set the environment variables of [configuration](configuration.md), and import from the subpaths (`openloops/core`, `openloops/mcps`, and so on). Users, login and tokens come from `nanosaas` (see [authentication](authentication.md)).
|
|
10
10
|
|
|
11
11
|
## Tell your coding agent where this is
|
|
12
12
|
|
|
@@ -21,18 +21,18 @@ The package has no controllers: the authorization of every endpoint is the respo
|
|
|
21
21
|
|
|
22
22
|
## The rule that matters most: always pass the user
|
|
23
23
|
|
|
24
|
-
The use cases check who owns every record, in the repository, with the `
|
|
24
|
+
The use cases check who owns every record, in the repository, with the `actor` you pass. Read [authorization](authorization.md) once.
|
|
25
25
|
|
|
26
26
|
- A record that is not the user's is answered as if it did not exist: a 404 `HttpError` from the functions that update or delete, and `null` from the getters, `getChatById` included.
|
|
27
|
-
- A call without `
|
|
28
|
-
- An administrator acts on the records of other users only with `scope: Scope.asAdmin(
|
|
27
|
+
- A call without `actor` fails with 401. Your endpoint is still the one that authenticates the request and builds the `actor` from the token.
|
|
28
|
+
- An administrator acts on the records of other users only with `scope: Scope.asAdmin(actor)`, and a worker or a webhook with `Scope.system('reason')`. Never build a scope from a value that comes from a request.
|
|
29
29
|
|
|
30
30
|
## Which endpoint calls what
|
|
31
31
|
|
|
32
32
|
| Your endpoint | `openloops` call |
|
|
33
33
|
| --- | --- |
|
|
34
|
-
| Send a message | `new Agent({ loop, tools, guards }).run({ input: { message, chatId? },
|
|
35
|
-
| Stop a running message | `Agent.interruptExecution(chatId,
|
|
34
|
+
| Send a message | `new Agent({ loop, tools, guards }).run({ input: { message, chatId? }, actor })` |
|
|
35
|
+
| Stop a running message | `Agent.interruptExecution(chatId, actor)` |
|
|
36
36
|
| List, read, delete chats | `listChatsByUser` (with `executionMode` to separate interactive from autonomous, `search` for the title and the messages, and `select` for a light history list), `getChatById`, `updateChat` to rename a chat with `title`, `deleteChat` |
|
|
37
37
|
| Poll the state of a chat | `getChatById({ id, select: { state: 1 } })` |
|
|
38
38
|
| Manage MCP servers | `createMcpServer`, `listMcpServersByUser`, `getMcpServerById`, `updateMcpServer`, `deleteMcpServer`, `verifyMcpServerConnection` |
|
|
@@ -43,7 +43,7 @@ The use cases check who owns every record, in the repository, with the `currentU
|
|
|
43
43
|
| Receive an event from another system | `receiveAutomationEvent`, public endpoint, authenticated only by the token of the automation |
|
|
44
44
|
| Tokens of an event automation | `issueAutomationEventToken`, `revokeAutomationEventToken`, `rotateAutomationEventTokens` |
|
|
45
45
|
| History of runs | `listAutomationRunsByAutomation`, `listAutomationRunsByUser` |
|
|
46
|
-
| "Run now" | `runner.runNow({ automationId,
|
|
46
|
+
| "Run now" | `runner.runNow({ automationId, actor })` |
|
|
47
47
|
| Sign in, sessions, users | `login`, `refreshSession`, `logout`, `issuePasswordResetToken`, `resetPassword`, `changePassword`, `createUser`, `getUserById`, `updateUser`, `deleteUser` |
|
|
48
48
|
|
|
49
49
|
## Running the agent for a message
|
|
@@ -51,10 +51,10 @@ The use cases check who owns every record, in the repository, with the `currentU
|
|
|
51
51
|
```typescript
|
|
52
52
|
import { Agent } from 'openloops/core'
|
|
53
53
|
import { AgiLoop } from 'openloops/loops'
|
|
54
|
-
import {
|
|
54
|
+
import { Actor } from 'nanosaas/common'
|
|
55
55
|
import { inputGuards } from 'openloops/guardrails'
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const actor = Actor.fromClaims({ userId: userIdFromYourAuth })
|
|
58
58
|
|
|
59
59
|
const agent = new Agent({
|
|
60
60
|
loop: new AgiLoop(),
|
|
@@ -64,7 +64,7 @@ const agent = new Agent({
|
|
|
64
64
|
|
|
65
65
|
const { data, error } = await agent.run({
|
|
66
66
|
input: { message, chatId },
|
|
67
|
-
|
|
67
|
+
actor,
|
|
68
68
|
})
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -103,7 +103,7 @@ Your users register their own servers, and every server must be approved before
|
|
|
103
103
|
Three parts, as described in [automations](automations.md):
|
|
104
104
|
|
|
105
105
|
1. Endpoints that create and manage automations and read their runs, from the table above.
|
|
106
|
-
2. If you use event triggers, one public endpoint that calls `receiveAutomationEvent` with the token of the `Authorization` header. It answers 202 without running the agent, and it is the only call that does not need a `
|
|
106
|
+
2. If you use event triggers, one public endpoint that calls `receiveAutomationEvent` with the token of the `Authorization` header. It answers 202 without running the agent, and it is the only call that does not need a `Actor`.
|
|
107
107
|
3. A worker process that you start once, with the options of the agent your automations should use:
|
|
108
108
|
|
|
109
109
|
```typescript
|
|
@@ -124,7 +124,7 @@ runner.start()
|
|
|
124
124
|
|
|
125
125
|
## Security checklist
|
|
126
126
|
|
|
127
|
-
- Pass the `
|
|
127
|
+
- Pass the `actor` of the request to every call, and build it from the verified token.
|
|
128
128
|
- Never take a `scope` from the body or the query of a request.
|
|
129
129
|
- Mask `headers` and `history` of MCP servers.
|
|
130
130
|
- Add input guards for what your product must never receive, such as card numbers.
|
package/docs/loops.md
CHANGED
package/docs/mcp-servers.md
CHANGED
|
@@ -29,7 +29,7 @@ const result = await createMcpServer({
|
|
|
29
29
|
Authorization: 'Bearer ...',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
actor,
|
|
33
33
|
})
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -60,10 +60,10 @@ The latest manifest is `history[0]`. The approved manifest is the entry of `hist
|
|
|
60
60
|
```typescript
|
|
61
61
|
const page = await listMcpServersByUser({
|
|
62
62
|
options: { page: 1, limit: 10 },
|
|
63
|
-
|
|
63
|
+
actor,
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
const all = await listAllMcpServersByUser({
|
|
66
|
+
const all = await listAllMcpServersByUser({ actor })
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
`listMcpServersByUser` is paginated (page 1, 10 per page by default) and sorted by last update, newest first. Use it for a management screen.
|
|
@@ -73,7 +73,7 @@ const all = await listAllMcpServersByUser({ currentUser })
|
|
|
73
73
|
## Getting one by id
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
|
-
const result = await getMcpServerById({ id: mcpServerId,
|
|
76
|
+
const result = await getMcpServerById({ id: mcpServerId, actor })
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
## Updating a server
|
|
@@ -86,7 +86,7 @@ const result = await updateMcpServer({
|
|
|
86
86
|
headers: { Authorization: 'Bearer <new-token>' },
|
|
87
87
|
__v: current.__v,
|
|
88
88
|
},
|
|
89
|
-
|
|
89
|
+
actor,
|
|
90
90
|
})
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -98,9 +98,9 @@ const result = await updateMcpServer({
|
|
|
98
98
|
## Deleting a server
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
|
-
await deleteMcpServer({ id: mcpServerId,
|
|
101
|
+
await deleteMcpServer({ id: mcpServerId, actor })
|
|
102
102
|
|
|
103
|
-
await deleteMcpServer({ id: mcpServerId, hardDelete: true,
|
|
103
|
+
await deleteMcpServer({ id: mcpServerId, hardDelete: true, actor })
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
The first one is a soft delete. A hard delete is for admins only.
|
|
@@ -108,7 +108,7 @@ The first one is a soft delete. A hard delete is for admins only.
|
|
|
108
108
|
## Checking the connection
|
|
109
109
|
|
|
110
110
|
```typescript
|
|
111
|
-
const result = await verifyMcpServerConnection({ id: mcpServerId,
|
|
111
|
+
const result = await verifyMcpServerConnection({ id: mcpServerId, actor })
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
Connects, reads the manifest and stores it in `history` if it is new, or stores a sanitized error and `status: 'error'`. The agent calls it by itself when it sees that a server changed. You can call it from a "test connection" button.
|
|
@@ -120,10 +120,10 @@ await decideMcpServerTrust({
|
|
|
120
120
|
id: mcpServerId,
|
|
121
121
|
decision: 'approve',
|
|
122
122
|
manifestHash: result.history[0].hash,
|
|
123
|
-
|
|
123
|
+
actor,
|
|
124
124
|
})
|
|
125
125
|
|
|
126
|
-
await decideMcpServerTrust({ id: mcpServerId, decision: 'block',
|
|
126
|
+
await decideMcpServerTrust({ id: mcpServerId, decision: 'block', actor })
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
- Approving requires the hash of the manifest the user reviewed, and it must be the latest one in `history`. If the server changed since the user looked at it, the call fails and the user has to review again.
|
|
@@ -168,7 +168,7 @@ agent.addInternalMcp({ name: 'other', url: 'https://other.example.com/mcp' })
|
|
|
168
168
|
|
|
169
169
|
await agent.run({
|
|
170
170
|
input: { message: 'how much did I spend on food this month?' },
|
|
171
|
-
|
|
171
|
+
actor,
|
|
172
172
|
mcpTokens: { budget: sessionToken },
|
|
173
173
|
})
|
|
174
174
|
```
|
|
@@ -213,7 +213,7 @@ const agent = new Agent({
|
|
|
213
213
|
|
|
214
214
|
await agent.run({
|
|
215
215
|
input: { message: 'summarize my week' },
|
|
216
|
-
|
|
216
|
+
actor,
|
|
217
217
|
mcpTokens: { budget: sessionToken, crm: sessionToken },
|
|
218
218
|
})
|
|
219
219
|
```
|
|
@@ -248,13 +248,13 @@ const mcp = await createInternalMcp({
|
|
|
248
248
|
url: 'https://api.example.com/mcp',
|
|
249
249
|
headers: { Authorization: 'Bearer {{token}}' },
|
|
250
250
|
},
|
|
251
|
-
|
|
251
|
+
actor: admin,
|
|
252
252
|
})
|
|
253
253
|
|
|
254
|
-
await updateInternalMcp({ id: mcp._id, payload: { enabled: false, __v: mcp.__v },
|
|
254
|
+
await updateInternalMcp({ id: mcp._id, payload: { enabled: false, __v: mcp.__v }, actor: admin })
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
- Every function needs an admin as `
|
|
257
|
+
- Every function needs an admin as `actor` and answers 403 otherwise. The sub-route separates the code, the permission is what protects it.
|
|
258
258
|
- `name` and `url` are required, `type` is always `http`, `environment` is optional and `enabled` defaults to `true`. A disabled server is not loaded. The name must be unique among the internal servers (409).
|
|
259
259
|
- A header with `{{token}}` uses `mcpTokens[name]` of the run. The stored servers have no `autonomousToken`, which exists only in the servers declared in code, so in an automation they are available only when the token is written in the header (for example `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U`), which is sent as it is in every run.
|
|
260
260
|
- Deleting is permanent. Internal servers have no owner, so they are not listed to any user.
|
package/docs/skills.md
CHANGED
|
@@ -65,7 +65,7 @@ if (result.can_answer) {
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
`ctx.skillParams` already carries the provider and model chosen for the chat, `sessionId`, `answerId`, the user's message, `
|
|
68
|
+
`ctx.skillParams` already carries the provider and model chosen for the chat, `sessionId`, `answerId`, the user's message, `actor`, `requestContext` and the current chat. You normally only add `contextInjection`.
|
|
69
69
|
|
|
70
70
|
| Run option | What it does |
|
|
71
71
|
| --- | --- |
|
package/docs/tools.md
CHANGED
|
@@ -29,7 +29,7 @@ export const greetUserTool = new Tool({
|
|
|
29
29
|
required: ['firstName'],
|
|
30
30
|
},
|
|
31
31
|
handler: async (params: Params): Promise<Output> => {
|
|
32
|
-
const {
|
|
32
|
+
const { actor, sessionId, answerId, firstName } = params
|
|
33
33
|
return { data: { greeting: `Hi ${firstName}` } }
|
|
34
34
|
},
|
|
35
35
|
})
|
|
@@ -43,7 +43,7 @@ export const greetUserTool = new Tool({
|
|
|
43
43
|
| `destructive` | `true` makes the agent ask the user to confirm before it runs. Defaults to `false`, so set it explicitly for anything that changes or deletes data. |
|
|
44
44
|
| `handler` | Receives the arguments plus `BaseParams` and returns `{ data }`. |
|
|
45
45
|
|
|
46
|
-
`BaseParams` (`
|
|
46
|
+
`BaseParams` (`actor`, `sessionId`, `answerId`) is always merged into the arguments your handler receives. Destructure and ignore the ones you don't need.
|
|
47
47
|
|
|
48
48
|
A `Tool` instance is shared. Never write to `this` inside a handler. Everything that varies between calls comes in through `params`.
|
|
49
49
|
|