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/dist/harness/agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActorLike, RequestContext } from 'nanosaas/common';
|
|
2
2
|
import { McpServer } from '../services/mcp-servers/entities/index.js';
|
|
3
3
|
import { Chat } from '../services/chats/entities/chat.entity.js';
|
|
4
4
|
import { ChatSettingsProps } from '../services/chats/entities/chat-settings.entity.js';
|
|
@@ -76,8 +76,8 @@ export declare class Agent {
|
|
|
76
76
|
private awaitingConfirmation;
|
|
77
77
|
private currentChat;
|
|
78
78
|
private chatOptions?;
|
|
79
|
-
private
|
|
80
|
-
private
|
|
79
|
+
private actor?;
|
|
80
|
+
private requestContext?;
|
|
81
81
|
private currentMessage;
|
|
82
82
|
private answerId;
|
|
83
83
|
private userMessageId?;
|
|
@@ -89,8 +89,8 @@ export declare class Agent {
|
|
|
89
89
|
private pipeline?;
|
|
90
90
|
private readonly snapshots;
|
|
91
91
|
private pendingNextNode?;
|
|
92
|
-
static interruptExecution(chatId: string,
|
|
93
|
-
static createChatSession(
|
|
92
|
+
static interruptExecution(chatId: string, actor: ActorLike): Promise<void>;
|
|
93
|
+
static createChatSession(actor: ActorLike, loop?: AgentLoop): Promise<Chat>;
|
|
94
94
|
constructor(agentOptions: AgentOptions);
|
|
95
95
|
get tools(): Tool[];
|
|
96
96
|
get mcps(): McpServer[];
|
|
@@ -100,8 +100,8 @@ export declare class Agent {
|
|
|
100
100
|
run(props: {
|
|
101
101
|
input: ChatInput;
|
|
102
102
|
options?: ChatSettingsProps;
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
actor: ActorLike;
|
|
104
|
+
requestContext?: RequestContext;
|
|
105
105
|
mcpTokens?: Record<string, string>;
|
|
106
106
|
usageLimit?: UsageLimit;
|
|
107
107
|
}): Promise<AgentRunResult>;
|
package/dist/harness/agent.js
CHANGED
|
@@ -22,9 +22,9 @@ __export(agent_exports, {
|
|
|
22
22
|
Agent: () => Agent
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(agent_exports);
|
|
25
|
+
var import_actor_profile = require("./actor-profile");
|
|
25
26
|
var import_mongodb = require("mongodb");
|
|
26
|
-
var
|
|
27
|
-
var import_error = require("../common/error/index.js");
|
|
27
|
+
var import_common = require("nanosaas/common");
|
|
28
28
|
var import_entities = require("../services/mcp-servers/entities/index.js");
|
|
29
29
|
var import_chats = require("../services/chats/index.js");
|
|
30
30
|
var import_chat = require("../services/chats/entities/chat.entity.js");
|
|
@@ -64,7 +64,7 @@ const AGENT_ERROR_CODES = {
|
|
|
64
64
|
};
|
|
65
65
|
const DEFAULT_MAX_ITERATIONS = 50;
|
|
66
66
|
class Agent {
|
|
67
|
-
logger = new
|
|
67
|
+
logger = new import_common.Logger();
|
|
68
68
|
_loop;
|
|
69
69
|
_identity;
|
|
70
70
|
_productInfo;
|
|
@@ -88,8 +88,8 @@ class Agent {
|
|
|
88
88
|
awaitingConfirmation = false;
|
|
89
89
|
currentChat;
|
|
90
90
|
chatOptions;
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
actor;
|
|
92
|
+
requestContext;
|
|
93
93
|
currentMessage = "";
|
|
94
94
|
answerId = "";
|
|
95
95
|
userMessageId;
|
|
@@ -101,21 +101,21 @@ class Agent {
|
|
|
101
101
|
pipeline;
|
|
102
102
|
snapshots = /* @__PURE__ */ new Map();
|
|
103
103
|
pendingNextNode;
|
|
104
|
-
static async interruptExecution(chatId,
|
|
105
|
-
const logger = new
|
|
104
|
+
static async interruptExecution(chatId, actor) {
|
|
105
|
+
const logger = new import_common.Logger();
|
|
106
106
|
logger.debug("[AGENT] Interrupt execution triggered");
|
|
107
107
|
await (0, import_chats.updateChat)({
|
|
108
108
|
id: chatId,
|
|
109
109
|
payload: { state: { stopRequested: true } },
|
|
110
|
-
|
|
110
|
+
actor
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
static async createChatSession(
|
|
114
|
-
if (!
|
|
113
|
+
static async createChatSession(actor, loop) {
|
|
114
|
+
if (!actor) throw new Error("[AGENT] actor is required to create a new chat");
|
|
115
115
|
const newChat = import_chat.Chat.withDefaults(loop?.name);
|
|
116
116
|
const data = await (0, import_chats.createChat)({
|
|
117
117
|
payload: newChat.toJSON(),
|
|
118
|
-
|
|
118
|
+
actor
|
|
119
119
|
});
|
|
120
120
|
if (!data) throw new Error("[AGENT] There was an error creating the chat");
|
|
121
121
|
return import_chat.Chat.fromJSON(data);
|
|
@@ -156,12 +156,12 @@ class Agent {
|
|
|
156
156
|
}
|
|
157
157
|
async run(props) {
|
|
158
158
|
try {
|
|
159
|
-
const { input, options,
|
|
159
|
+
const { input, options, actor, requestContext, mcpTokens, usageLimit } = props || {};
|
|
160
160
|
const { chatId, message } = input || {};
|
|
161
161
|
this.logger.debug(input, "[AGENT] Agent started");
|
|
162
162
|
if (!this._loop?.nodes || !this._loop?.initialNode) throw new Error("[AGENT] Loop is missing");
|
|
163
163
|
if (!message) throw new Error("[AGENT] Message is required");
|
|
164
|
-
if (!
|
|
164
|
+
if (!actor) throw new Error("[AGENT] actor is required");
|
|
165
165
|
this.stopLoop = false;
|
|
166
166
|
this.stopRequested = false;
|
|
167
167
|
this.pendingNextNode = void 0;
|
|
@@ -175,8 +175,8 @@ class Agent {
|
|
|
175
175
|
this.iteration = 0;
|
|
176
176
|
this.userMessageId = void 0;
|
|
177
177
|
this.awaitingConfirmation = false;
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
178
|
+
this.actor = await (0, import_actor_profile.withProfile)(actor);
|
|
179
|
+
this.requestContext = requestContext;
|
|
180
180
|
this.currentMessage = message;
|
|
181
181
|
this.chatOptions = options;
|
|
182
182
|
this.mcpTokens = mcpTokens ?? {};
|
|
@@ -189,7 +189,7 @@ class Agent {
|
|
|
189
189
|
this.answerId = new import_mongodb.ObjectId().toString();
|
|
190
190
|
if (usageLimit) {
|
|
191
191
|
try {
|
|
192
|
-
await (0, import_usage_limit.checkUsageLimit)(usageLimit,
|
|
192
|
+
await (0, import_usage_limit.checkUsageLimit)(usageLimit, actor);
|
|
193
193
|
} catch (error) {
|
|
194
194
|
if (error instanceof import_usage_limit.UsageLimitError) return this.usageLimitResult(error, await this.saveBlockedMessage(chatId));
|
|
195
195
|
throw error;
|
|
@@ -253,13 +253,13 @@ class Agent {
|
|
|
253
253
|
async preRunner(chatId) {
|
|
254
254
|
let chatData;
|
|
255
255
|
if (chatId) {
|
|
256
|
-
const data = await (0, import_chats.getChatById)({ id: chatId,
|
|
256
|
+
const data = await (0, import_chats.getChatById)({ id: chatId, actor: this.actor });
|
|
257
257
|
chatData = data?._id ? data : void 0;
|
|
258
258
|
}
|
|
259
259
|
if (!chatData) {
|
|
260
260
|
this.logger.debug("[AGENT] Not existing chat found");
|
|
261
|
-
if (!this.
|
|
262
|
-
this.currentChat = await Agent.createChatSession(this.
|
|
261
|
+
if (!this.actor) throw new Error("[AGENT] ActorLike params is required");
|
|
262
|
+
this.currentChat = await Agent.createChatSession(this.actor, this._loop);
|
|
263
263
|
this.currentChat.settings?.setExecutionMode(this.executionMode);
|
|
264
264
|
} else {
|
|
265
265
|
this.logger.debug("[AGENT] Existing chat found");
|
|
@@ -280,7 +280,7 @@ class Agent {
|
|
|
280
280
|
this.model = (0, import_model_resolution.resolveModel)({
|
|
281
281
|
run: (0, import_model_resolution.toModelRef)({ provider: this.chatOptions?.modelProvider, model: this.chatOptions?.modelName }),
|
|
282
282
|
chat: (0, import_model_resolution.toModelRef)({ provider: this.currentChat.settings?.modelProvider, model: this.currentChat.settings?.modelName }),
|
|
283
|
-
user: (0, import_model_resolution.toModelRef)(this.
|
|
283
|
+
user: (0, import_model_resolution.toModelRef)(this.actor?.profile?.preferences?.defaultModel),
|
|
284
284
|
agent: this.fallbackModel
|
|
285
285
|
});
|
|
286
286
|
this.currentChat.settings?.setModelProvider(this.model.provider);
|
|
@@ -305,8 +305,8 @@ class Agent {
|
|
|
305
305
|
const context = {
|
|
306
306
|
message: this.currentMessage,
|
|
307
307
|
chat: ctx.chat,
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
actor: ctx.actor,
|
|
309
|
+
requestContext: ctx.requestContext,
|
|
310
310
|
skillParams: ctx.skillParams,
|
|
311
311
|
logger: ctx.logger
|
|
312
312
|
};
|
|
@@ -403,12 +403,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
403
403
|
await this.disconnectMcpServers();
|
|
404
404
|
}
|
|
405
405
|
async reportFailure(error, details = {}) {
|
|
406
|
-
await (0,
|
|
406
|
+
await (0, import_common.reportError)(error, { source: "agent", chatId: this.currentChat?._id?.toString(), userId: this.actor?.userId, ...details });
|
|
407
407
|
}
|
|
408
408
|
async saveBlockedMessage(chatId) {
|
|
409
409
|
if (!chatId) return void 0;
|
|
410
410
|
try {
|
|
411
|
-
const data = await (0, import_chats.getChatById)({ id: chatId,
|
|
411
|
+
const data = await (0, import_chats.getChatById)({ id: chatId, actor: this.actor });
|
|
412
412
|
if (!data?._id) return void 0;
|
|
413
413
|
this.currentChat = import_chat.Chat.fromJSON(data);
|
|
414
414
|
if (!this.currentChat.messages?.length) this.currentChat.setTitle(this.currentMessage);
|
|
@@ -444,11 +444,11 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
444
444
|
async loadTasks() {
|
|
445
445
|
const chatId = this.currentChat._id?.toString();
|
|
446
446
|
if (!chatId) return;
|
|
447
|
-
const { items: taskDocs } = await (0, import_tasks.listAgentTasksByChat)({ chatId,
|
|
447
|
+
const { items: taskDocs } = await (0, import_tasks.listAgentTasksByChat)({ chatId, actor: this.actor });
|
|
448
448
|
const tasks = taskDocs.map((doc) => import_agent_task.AgentTask.fromJSON(doc)).reverse();
|
|
449
449
|
const activeTaskId = this.currentChat.state?.activeTaskId;
|
|
450
450
|
if (activeTaskId && !tasks.some((task) => task.id === activeTaskId)) {
|
|
451
|
-
const data = await (0, import_tasks.getAgentTaskById)({ id: activeTaskId,
|
|
451
|
+
const data = await (0, import_tasks.getAgentTaskById)({ id: activeTaskId, actor: this.actor });
|
|
452
452
|
if (data) tasks.push(import_agent_task.AgentTask.fromJSON(data));
|
|
453
453
|
}
|
|
454
454
|
for (const task of tasks) {
|
|
@@ -463,7 +463,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
463
463
|
}
|
|
464
464
|
async hydrateTask(task) {
|
|
465
465
|
if (task.hydrated) return;
|
|
466
|
-
const { items } = await (0, import_tasks.listAgentActionsByTask)({ taskId: task.id,
|
|
466
|
+
const { items } = await (0, import_tasks.listAgentActionsByTask)({ taskId: task.id, actor: this.actor });
|
|
467
467
|
const actions = items.map((doc) => import_agent_action.AgentAction.fromJSON(doc));
|
|
468
468
|
for (const action of actions) this.snapshots.set(`action:${action.id}`, this.fingerprint(action));
|
|
469
469
|
task.setActions(actions);
|
|
@@ -474,9 +474,9 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
474
474
|
const previous = this.snapshots.get(key);
|
|
475
475
|
if (previous === current) return;
|
|
476
476
|
if (previous === void 0) {
|
|
477
|
-
await (0, import_tasks.createAgentTask)({ payload: task.toJSON(),
|
|
477
|
+
await (0, import_tasks.createAgentTask)({ payload: task.toJSON(), actor: this.actor });
|
|
478
478
|
} else {
|
|
479
|
-
await (0, import_tasks.updateAgentTask)({ id: task.id, payload: task.toJSON(),
|
|
479
|
+
await (0, import_tasks.updateAgentTask)({ id: task.id, payload: task.toJSON(), actor: this.actor });
|
|
480
480
|
}
|
|
481
481
|
this.snapshots.set(key, current);
|
|
482
482
|
}
|
|
@@ -486,9 +486,9 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
486
486
|
const previous = this.snapshots.get(key);
|
|
487
487
|
if (previous === current) return;
|
|
488
488
|
if (previous === void 0) {
|
|
489
|
-
await (0, import_tasks.createAgentAction)({ payload: action.toJSON(),
|
|
489
|
+
await (0, import_tasks.createAgentAction)({ payload: action.toJSON(), actor: this.actor });
|
|
490
490
|
} else {
|
|
491
|
-
await (0, import_tasks.updateAgentAction)({ id: action.id, payload: action.toJSON(),
|
|
491
|
+
await (0, import_tasks.updateAgentAction)({ id: action.id, payload: action.toJSON(), actor: this.actor });
|
|
492
492
|
}
|
|
493
493
|
this.snapshots.set(key, current);
|
|
494
494
|
}
|
|
@@ -517,7 +517,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
517
517
|
iteration: trace.iteration ?? this.iteration,
|
|
518
518
|
durationMs: trace.durationMs
|
|
519
519
|
})),
|
|
520
|
-
|
|
520
|
+
actor: this.actor
|
|
521
521
|
});
|
|
522
522
|
} catch (error) {
|
|
523
523
|
this.logger.error({ error: error?.message ?? error }, "[AGENT] Failed to persist traces");
|
|
@@ -534,7 +534,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
534
534
|
return this.mcpListing.then(() => this.tools);
|
|
535
535
|
}
|
|
536
536
|
async listMcps() {
|
|
537
|
-
if (!this.
|
|
537
|
+
if (!this.actor) return;
|
|
538
538
|
const internals = [...this._internalMcps];
|
|
539
539
|
try {
|
|
540
540
|
for (const mcp of await (0, import_internal.listActiveInternalMcps)()) if (!internals.some((candidate) => candidate.name === mcp.name)) internals.push(mcp);
|
|
@@ -544,7 +544,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
544
544
|
}
|
|
545
545
|
this._mcps = internals.map((mcp) => this.toInternalEntry(mcp));
|
|
546
546
|
try {
|
|
547
|
-
const response = await (0, import_mcp_servers.listAllMcpServersByUser)({
|
|
547
|
+
const response = await (0, import_mcp_servers.listAllMcpServersByUser)({ actor: this.actor });
|
|
548
548
|
const reserved = new Set(internals.map((mcp) => mcp.name));
|
|
549
549
|
const stored = response.items.filter((props) => {
|
|
550
550
|
if (!reserved.has(props.name)) return true;
|
|
@@ -579,7 +579,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
579
579
|
if (!Object.values(headers).some((value) => value.includes(TOKEN_PLACEHOLDER))) return headers;
|
|
580
580
|
const own = this.mcpTokens[mcp.name];
|
|
581
581
|
const token = own || (this.executionMode === "autonomous" ? mcp.autonomousToken : void 0);
|
|
582
|
-
const userId = this.
|
|
582
|
+
const userId = this.actor?.userId;
|
|
583
583
|
if (!token || !userId) return void 0;
|
|
584
584
|
for (const [name, value] of Object.entries(headers)) headers[name] = value.split(TOKEN_PLACEHOLDER).join(token);
|
|
585
585
|
if (!own) {
|
|
@@ -651,7 +651,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
651
651
|
entry.hash = live.hash;
|
|
652
652
|
if (entry.server.latest?.hash !== live.hash) {
|
|
653
653
|
try {
|
|
654
|
-
const data = await (0, import_mcp_servers.verifyMcpServerConnection)({ id: entry.id,
|
|
654
|
+
const data = await (0, import_mcp_servers.verifyMcpServerConnection)({ id: entry.id, actor: this.actor });
|
|
655
655
|
this.refreshMcpServer(entry, data);
|
|
656
656
|
} catch (error) {
|
|
657
657
|
this.logger.error({ error: error?.message ?? error, mcpServer: entry.name }, "[AGENT] Failed to verify MCP server");
|
|
@@ -733,7 +733,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
733
733
|
}
|
|
734
734
|
async decideMcp(entry, decision, manifestHash) {
|
|
735
735
|
try {
|
|
736
|
-
const data = await (0, import_mcp_servers.decideMcpServerTrust)({ id: entry.id, decision, manifestHash,
|
|
736
|
+
const data = await (0, import_mcp_servers.decideMcpServerTrust)({ id: entry.id, decision, manifestHash, actor: this.actor });
|
|
737
737
|
this.refreshMcpServer(entry, data);
|
|
738
738
|
return true;
|
|
739
739
|
} catch (error) {
|
|
@@ -785,13 +785,13 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
785
785
|
const current = JSON.stringify({ payload, unset });
|
|
786
786
|
if (this.snapshots.get(key) === current) return;
|
|
787
787
|
this.logger.debug("[AGENT] Updating chat...");
|
|
788
|
-
await (0, import_chats.updateChat)({ id, payload, unset,
|
|
788
|
+
await (0, import_chats.updateChat)({ id, payload, unset, actor: this.actor });
|
|
789
789
|
this.snapshots.set(key, current);
|
|
790
790
|
}
|
|
791
791
|
async checkInterruptionRequest() {
|
|
792
792
|
const chatId = this.currentChat?._id?.toString();
|
|
793
793
|
if (!chatId) return;
|
|
794
|
-
const data = await (0, import_chats.getChatById)({ id: chatId, select: { state: 1 },
|
|
794
|
+
const data = await (0, import_chats.getChatById)({ id: chatId, select: { state: 1 }, actor: this.actor });
|
|
795
795
|
if (data?.state?.stopRequested) this.stopRequested = true;
|
|
796
796
|
}
|
|
797
797
|
async runLoop() {
|
|
@@ -812,7 +812,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
812
812
|
this.stopLoop = true;
|
|
813
813
|
break;
|
|
814
814
|
}
|
|
815
|
-
if (iterations > 0 && this.stopOnUsageLimit && this.usageLimit) await (0, import_usage_limit.checkUsageLimit)(this.usageLimit, this.
|
|
815
|
+
if (iterations > 0 && this.stopOnUsageLimit && this.usageLimit) await (0, import_usage_limit.checkUsageLimit)(this.usageLimit, this.actor);
|
|
816
816
|
iterations++;
|
|
817
817
|
this.iteration = iterations;
|
|
818
818
|
await this.checkInterruptionRequest();
|
|
@@ -889,13 +889,13 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
889
889
|
}
|
|
890
890
|
get baseParams() {
|
|
891
891
|
return {
|
|
892
|
-
|
|
892
|
+
actor: this.actor,
|
|
893
893
|
sessionId: this.currentChat._id?.toString() ?? "",
|
|
894
894
|
answerId: this.answerId
|
|
895
895
|
};
|
|
896
896
|
}
|
|
897
897
|
getWorkspace() {
|
|
898
|
-
this.workspace ??= new import_workspace.AgentWorkspace(this.currentChat._id.toString(), this.
|
|
898
|
+
this.workspace ??= new import_workspace.AgentWorkspace(this.currentChat._id.toString(), this.actor, this.answerId);
|
|
899
899
|
return this.workspace;
|
|
900
900
|
}
|
|
901
901
|
getPipeline() {
|
|
@@ -927,8 +927,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
927
927
|
chat: this.currentChat,
|
|
928
928
|
chatOptions: this.chatOptions,
|
|
929
929
|
thinkingEffort: this.thinkingEffort,
|
|
930
|
-
|
|
931
|
-
|
|
930
|
+
actor: this.actor,
|
|
931
|
+
requestContext: this.requestContext,
|
|
932
932
|
currentMessage: this.currentMessage,
|
|
933
933
|
answerId: this.answerId,
|
|
934
934
|
get tools() {
|
|
@@ -941,8 +941,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
941
941
|
sessionId,
|
|
942
942
|
answerId: this.answerId,
|
|
943
943
|
userMessage: this.currentMessage,
|
|
944
|
-
|
|
945
|
-
|
|
944
|
+
actor: this.actor,
|
|
945
|
+
requestContext: this.requestContext,
|
|
946
946
|
chat: this.currentChat
|
|
947
947
|
},
|
|
948
948
|
logger: this.logger
|
package/dist/harness/agent.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { withProfile } from "./actor-profile";
|
|
1
2
|
import { ObjectId } from "mongodb";
|
|
2
|
-
import { Logger } from "
|
|
3
|
-
import { reportError } from "../common/error/index.js";
|
|
3
|
+
import { Logger, reportError } from "nanosaas/common";
|
|
4
4
|
import { McpServer, needsUserReview } from "../services/mcp-servers/entities/index.js";
|
|
5
5
|
import { createChat, updateChat, getChatById } from "../services/chats/index.js";
|
|
6
6
|
import { Chat } from "../services/chats/entities/chat.entity.js";
|
|
@@ -72,8 +72,8 @@ class Agent {
|
|
|
72
72
|
awaitingConfirmation = false;
|
|
73
73
|
currentChat;
|
|
74
74
|
chatOptions;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
actor;
|
|
76
|
+
requestContext;
|
|
77
77
|
currentMessage = "";
|
|
78
78
|
answerId = "";
|
|
79
79
|
userMessageId;
|
|
@@ -85,21 +85,21 @@ class Agent {
|
|
|
85
85
|
pipeline;
|
|
86
86
|
snapshots = /* @__PURE__ */ new Map();
|
|
87
87
|
pendingNextNode;
|
|
88
|
-
static async interruptExecution(chatId,
|
|
88
|
+
static async interruptExecution(chatId, actor) {
|
|
89
89
|
const logger = new Logger();
|
|
90
90
|
logger.debug("[AGENT] Interrupt execution triggered");
|
|
91
91
|
await updateChat({
|
|
92
92
|
id: chatId,
|
|
93
93
|
payload: { state: { stopRequested: true } },
|
|
94
|
-
|
|
94
|
+
actor
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
static async createChatSession(
|
|
98
|
-
if (!
|
|
97
|
+
static async createChatSession(actor, loop) {
|
|
98
|
+
if (!actor) throw new Error("[AGENT] actor is required to create a new chat");
|
|
99
99
|
const newChat = Chat.withDefaults(loop?.name);
|
|
100
100
|
const data = await createChat({
|
|
101
101
|
payload: newChat.toJSON(),
|
|
102
|
-
|
|
102
|
+
actor
|
|
103
103
|
});
|
|
104
104
|
if (!data) throw new Error("[AGENT] There was an error creating the chat");
|
|
105
105
|
return Chat.fromJSON(data);
|
|
@@ -140,12 +140,12 @@ class Agent {
|
|
|
140
140
|
}
|
|
141
141
|
async run(props) {
|
|
142
142
|
try {
|
|
143
|
-
const { input, options,
|
|
143
|
+
const { input, options, actor, requestContext, mcpTokens, usageLimit } = props || {};
|
|
144
144
|
const { chatId, message } = input || {};
|
|
145
145
|
this.logger.debug(input, "[AGENT] Agent started");
|
|
146
146
|
if (!this._loop?.nodes || !this._loop?.initialNode) throw new Error("[AGENT] Loop is missing");
|
|
147
147
|
if (!message) throw new Error("[AGENT] Message is required");
|
|
148
|
-
if (!
|
|
148
|
+
if (!actor) throw new Error("[AGENT] actor is required");
|
|
149
149
|
this.stopLoop = false;
|
|
150
150
|
this.stopRequested = false;
|
|
151
151
|
this.pendingNextNode = void 0;
|
|
@@ -159,8 +159,8 @@ class Agent {
|
|
|
159
159
|
this.iteration = 0;
|
|
160
160
|
this.userMessageId = void 0;
|
|
161
161
|
this.awaitingConfirmation = false;
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
162
|
+
this.actor = await withProfile(actor);
|
|
163
|
+
this.requestContext = requestContext;
|
|
164
164
|
this.currentMessage = message;
|
|
165
165
|
this.chatOptions = options;
|
|
166
166
|
this.mcpTokens = mcpTokens ?? {};
|
|
@@ -173,7 +173,7 @@ class Agent {
|
|
|
173
173
|
this.answerId = new ObjectId().toString();
|
|
174
174
|
if (usageLimit) {
|
|
175
175
|
try {
|
|
176
|
-
await checkUsageLimit(usageLimit,
|
|
176
|
+
await checkUsageLimit(usageLimit, actor);
|
|
177
177
|
} catch (error) {
|
|
178
178
|
if (error instanceof UsageLimitError) return this.usageLimitResult(error, await this.saveBlockedMessage(chatId));
|
|
179
179
|
throw error;
|
|
@@ -237,13 +237,13 @@ class Agent {
|
|
|
237
237
|
async preRunner(chatId) {
|
|
238
238
|
let chatData;
|
|
239
239
|
if (chatId) {
|
|
240
|
-
const data = await getChatById({ id: chatId,
|
|
240
|
+
const data = await getChatById({ id: chatId, actor: this.actor });
|
|
241
241
|
chatData = data?._id ? data : void 0;
|
|
242
242
|
}
|
|
243
243
|
if (!chatData) {
|
|
244
244
|
this.logger.debug("[AGENT] Not existing chat found");
|
|
245
|
-
if (!this.
|
|
246
|
-
this.currentChat = await Agent.createChatSession(this.
|
|
245
|
+
if (!this.actor) throw new Error("[AGENT] ActorLike params is required");
|
|
246
|
+
this.currentChat = await Agent.createChatSession(this.actor, this._loop);
|
|
247
247
|
this.currentChat.settings?.setExecutionMode(this.executionMode);
|
|
248
248
|
} else {
|
|
249
249
|
this.logger.debug("[AGENT] Existing chat found");
|
|
@@ -264,7 +264,7 @@ class Agent {
|
|
|
264
264
|
this.model = resolveModel({
|
|
265
265
|
run: toModelRef({ provider: this.chatOptions?.modelProvider, model: this.chatOptions?.modelName }),
|
|
266
266
|
chat: toModelRef({ provider: this.currentChat.settings?.modelProvider, model: this.currentChat.settings?.modelName }),
|
|
267
|
-
user: toModelRef(this.
|
|
267
|
+
user: toModelRef(this.actor?.profile?.preferences?.defaultModel),
|
|
268
268
|
agent: this.fallbackModel
|
|
269
269
|
});
|
|
270
270
|
this.currentChat.settings?.setModelProvider(this.model.provider);
|
|
@@ -289,8 +289,8 @@ class Agent {
|
|
|
289
289
|
const context = {
|
|
290
290
|
message: this.currentMessage,
|
|
291
291
|
chat: ctx.chat,
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
actor: ctx.actor,
|
|
293
|
+
requestContext: ctx.requestContext,
|
|
294
294
|
skillParams: ctx.skillParams,
|
|
295
295
|
logger: ctx.logger
|
|
296
296
|
};
|
|
@@ -387,12 +387,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
387
387
|
await this.disconnectMcpServers();
|
|
388
388
|
}
|
|
389
389
|
async reportFailure(error, details = {}) {
|
|
390
|
-
await reportError(error, { source: "agent", chatId: this.currentChat?._id?.toString(), userId: this.
|
|
390
|
+
await reportError(error, { source: "agent", chatId: this.currentChat?._id?.toString(), userId: this.actor?.userId, ...details });
|
|
391
391
|
}
|
|
392
392
|
async saveBlockedMessage(chatId) {
|
|
393
393
|
if (!chatId) return void 0;
|
|
394
394
|
try {
|
|
395
|
-
const data = await getChatById({ id: chatId,
|
|
395
|
+
const data = await getChatById({ id: chatId, actor: this.actor });
|
|
396
396
|
if (!data?._id) return void 0;
|
|
397
397
|
this.currentChat = Chat.fromJSON(data);
|
|
398
398
|
if (!this.currentChat.messages?.length) this.currentChat.setTitle(this.currentMessage);
|
|
@@ -428,11 +428,11 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
428
428
|
async loadTasks() {
|
|
429
429
|
const chatId = this.currentChat._id?.toString();
|
|
430
430
|
if (!chatId) return;
|
|
431
|
-
const { items: taskDocs } = await listAgentTasksByChat({ chatId,
|
|
431
|
+
const { items: taskDocs } = await listAgentTasksByChat({ chatId, actor: this.actor });
|
|
432
432
|
const tasks = taskDocs.map((doc) => AgentTask.fromJSON(doc)).reverse();
|
|
433
433
|
const activeTaskId = this.currentChat.state?.activeTaskId;
|
|
434
434
|
if (activeTaskId && !tasks.some((task) => task.id === activeTaskId)) {
|
|
435
|
-
const data = await getAgentTaskById({ id: activeTaskId,
|
|
435
|
+
const data = await getAgentTaskById({ id: activeTaskId, actor: this.actor });
|
|
436
436
|
if (data) tasks.push(AgentTask.fromJSON(data));
|
|
437
437
|
}
|
|
438
438
|
for (const task of tasks) {
|
|
@@ -447,7 +447,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
447
447
|
}
|
|
448
448
|
async hydrateTask(task) {
|
|
449
449
|
if (task.hydrated) return;
|
|
450
|
-
const { items } = await listAgentActionsByTask({ taskId: task.id,
|
|
450
|
+
const { items } = await listAgentActionsByTask({ taskId: task.id, actor: this.actor });
|
|
451
451
|
const actions = items.map((doc) => AgentAction.fromJSON(doc));
|
|
452
452
|
for (const action of actions) this.snapshots.set(`action:${action.id}`, this.fingerprint(action));
|
|
453
453
|
task.setActions(actions);
|
|
@@ -458,9 +458,9 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
458
458
|
const previous = this.snapshots.get(key);
|
|
459
459
|
if (previous === current) return;
|
|
460
460
|
if (previous === void 0) {
|
|
461
|
-
await createAgentTask({ payload: task.toJSON(),
|
|
461
|
+
await createAgentTask({ payload: task.toJSON(), actor: this.actor });
|
|
462
462
|
} else {
|
|
463
|
-
await updateAgentTask({ id: task.id, payload: task.toJSON(),
|
|
463
|
+
await updateAgentTask({ id: task.id, payload: task.toJSON(), actor: this.actor });
|
|
464
464
|
}
|
|
465
465
|
this.snapshots.set(key, current);
|
|
466
466
|
}
|
|
@@ -470,9 +470,9 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
470
470
|
const previous = this.snapshots.get(key);
|
|
471
471
|
if (previous === current) return;
|
|
472
472
|
if (previous === void 0) {
|
|
473
|
-
await createAgentAction({ payload: action.toJSON(),
|
|
473
|
+
await createAgentAction({ payload: action.toJSON(), actor: this.actor });
|
|
474
474
|
} else {
|
|
475
|
-
await updateAgentAction({ id: action.id, payload: action.toJSON(),
|
|
475
|
+
await updateAgentAction({ id: action.id, payload: action.toJSON(), actor: this.actor });
|
|
476
476
|
}
|
|
477
477
|
this.snapshots.set(key, current);
|
|
478
478
|
}
|
|
@@ -501,7 +501,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
501
501
|
iteration: trace.iteration ?? this.iteration,
|
|
502
502
|
durationMs: trace.durationMs
|
|
503
503
|
})),
|
|
504
|
-
|
|
504
|
+
actor: this.actor
|
|
505
505
|
});
|
|
506
506
|
} catch (error) {
|
|
507
507
|
this.logger.error({ error: error?.message ?? error }, "[AGENT] Failed to persist traces");
|
|
@@ -518,7 +518,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
518
518
|
return this.mcpListing.then(() => this.tools);
|
|
519
519
|
}
|
|
520
520
|
async listMcps() {
|
|
521
|
-
if (!this.
|
|
521
|
+
if (!this.actor) return;
|
|
522
522
|
const internals = [...this._internalMcps];
|
|
523
523
|
try {
|
|
524
524
|
for (const mcp of await listActiveInternalMcps()) if (!internals.some((candidate) => candidate.name === mcp.name)) internals.push(mcp);
|
|
@@ -528,7 +528,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
528
528
|
}
|
|
529
529
|
this._mcps = internals.map((mcp) => this.toInternalEntry(mcp));
|
|
530
530
|
try {
|
|
531
|
-
const response = await listAllMcpServersByUser({
|
|
531
|
+
const response = await listAllMcpServersByUser({ actor: this.actor });
|
|
532
532
|
const reserved = new Set(internals.map((mcp) => mcp.name));
|
|
533
533
|
const stored = response.items.filter((props) => {
|
|
534
534
|
if (!reserved.has(props.name)) return true;
|
|
@@ -563,7 +563,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
563
563
|
if (!Object.values(headers).some((value) => value.includes(TOKEN_PLACEHOLDER))) return headers;
|
|
564
564
|
const own = this.mcpTokens[mcp.name];
|
|
565
565
|
const token = own || (this.executionMode === "autonomous" ? mcp.autonomousToken : void 0);
|
|
566
|
-
const userId = this.
|
|
566
|
+
const userId = this.actor?.userId;
|
|
567
567
|
if (!token || !userId) return void 0;
|
|
568
568
|
for (const [name, value] of Object.entries(headers)) headers[name] = value.split(TOKEN_PLACEHOLDER).join(token);
|
|
569
569
|
if (!own) {
|
|
@@ -635,7 +635,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
635
635
|
entry.hash = live.hash;
|
|
636
636
|
if (entry.server.latest?.hash !== live.hash) {
|
|
637
637
|
try {
|
|
638
|
-
const data = await verifyMcpServerConnection({ id: entry.id,
|
|
638
|
+
const data = await verifyMcpServerConnection({ id: entry.id, actor: this.actor });
|
|
639
639
|
this.refreshMcpServer(entry, data);
|
|
640
640
|
} catch (error) {
|
|
641
641
|
this.logger.error({ error: error?.message ?? error, mcpServer: entry.name }, "[AGENT] Failed to verify MCP server");
|
|
@@ -717,7 +717,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
717
717
|
}
|
|
718
718
|
async decideMcp(entry, decision, manifestHash) {
|
|
719
719
|
try {
|
|
720
|
-
const data = await decideMcpServerTrust({ id: entry.id, decision, manifestHash,
|
|
720
|
+
const data = await decideMcpServerTrust({ id: entry.id, decision, manifestHash, actor: this.actor });
|
|
721
721
|
this.refreshMcpServer(entry, data);
|
|
722
722
|
return true;
|
|
723
723
|
} catch (error) {
|
|
@@ -769,13 +769,13 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
769
769
|
const current = JSON.stringify({ payload, unset });
|
|
770
770
|
if (this.snapshots.get(key) === current) return;
|
|
771
771
|
this.logger.debug("[AGENT] Updating chat...");
|
|
772
|
-
await updateChat({ id, payload, unset,
|
|
772
|
+
await updateChat({ id, payload, unset, actor: this.actor });
|
|
773
773
|
this.snapshots.set(key, current);
|
|
774
774
|
}
|
|
775
775
|
async checkInterruptionRequest() {
|
|
776
776
|
const chatId = this.currentChat?._id?.toString();
|
|
777
777
|
if (!chatId) return;
|
|
778
|
-
const data = await getChatById({ id: chatId, select: { state: 1 },
|
|
778
|
+
const data = await getChatById({ id: chatId, select: { state: 1 }, actor: this.actor });
|
|
779
779
|
if (data?.state?.stopRequested) this.stopRequested = true;
|
|
780
780
|
}
|
|
781
781
|
async runLoop() {
|
|
@@ -796,7 +796,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
796
796
|
this.stopLoop = true;
|
|
797
797
|
break;
|
|
798
798
|
}
|
|
799
|
-
if (iterations > 0 && this.stopOnUsageLimit && this.usageLimit) await checkUsageLimit(this.usageLimit, this.
|
|
799
|
+
if (iterations > 0 && this.stopOnUsageLimit && this.usageLimit) await checkUsageLimit(this.usageLimit, this.actor);
|
|
800
800
|
iterations++;
|
|
801
801
|
this.iteration = iterations;
|
|
802
802
|
await this.checkInterruptionRequest();
|
|
@@ -873,13 +873,13 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
873
873
|
}
|
|
874
874
|
get baseParams() {
|
|
875
875
|
return {
|
|
876
|
-
|
|
876
|
+
actor: this.actor,
|
|
877
877
|
sessionId: this.currentChat._id?.toString() ?? "",
|
|
878
878
|
answerId: this.answerId
|
|
879
879
|
};
|
|
880
880
|
}
|
|
881
881
|
getWorkspace() {
|
|
882
|
-
this.workspace ??= new AgentWorkspace(this.currentChat._id.toString(), this.
|
|
882
|
+
this.workspace ??= new AgentWorkspace(this.currentChat._id.toString(), this.actor, this.answerId);
|
|
883
883
|
return this.workspace;
|
|
884
884
|
}
|
|
885
885
|
getPipeline() {
|
|
@@ -911,8 +911,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
911
911
|
chat: this.currentChat,
|
|
912
912
|
chatOptions: this.chatOptions,
|
|
913
913
|
thinkingEffort: this.thinkingEffort,
|
|
914
|
-
|
|
915
|
-
|
|
914
|
+
actor: this.actor,
|
|
915
|
+
requestContext: this.requestContext,
|
|
916
916
|
currentMessage: this.currentMessage,
|
|
917
917
|
answerId: this.answerId,
|
|
918
918
|
get tools() {
|
|
@@ -925,8 +925,8 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
925
925
|
sessionId,
|
|
926
926
|
answerId: this.answerId,
|
|
927
927
|
userMessage: this.currentMessage,
|
|
928
|
-
|
|
929
|
-
|
|
928
|
+
actor: this.actor,
|
|
929
|
+
requestContext: this.requestContext,
|
|
930
930
|
chat: this.currentChat
|
|
931
931
|
},
|
|
932
932
|
logger: this.logger
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ScopeUser } from 'nanosaas/db';
|
|
2
|
+
import { UserProps } from 'nanosaas/users';
|
|
3
|
+
export interface DefaultModelProps {
|
|
4
|
+
provider?: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class DefaultModel {
|
|
8
|
+
provider?: string | undefined;
|
|
9
|
+
model?: string | undefined;
|
|
10
|
+
constructor(provider?: string | undefined, model?: string | undefined);
|
|
11
|
+
static fromJSON(props: DefaultModelProps): DefaultModel;
|
|
12
|
+
toJSON(): DefaultModelProps;
|
|
13
|
+
}
|
|
14
|
+
export declare const registerDefaultModelExtension: () => void;
|
|
15
|
+
export interface SetDefaultModelParams {
|
|
16
|
+
id: string;
|
|
17
|
+
model: DefaultModelProps | null;
|
|
18
|
+
actor: ScopeUser;
|
|
19
|
+
}
|
|
20
|
+
export declare function setDefaultModel(params: SetDefaultModelParams): Promise<UserProps>;
|