openloops 0.6.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/dist/clients/llm/llm-client.mjs +0 -1
- package/dist/clients/llm/llm-error.mjs +0 -1
- package/dist/clients/llm/llm-types.mjs +0 -1
- package/dist/clients/llm/model-resolution.mjs +0 -1
- package/dist/clients/llm/pi-ai-adapter.mjs +0 -1
- package/dist/clients/llm/sampling-rules.mjs +0 -1
- package/dist/clients/serper/serper-client.mjs +0 -1
- package/dist/clients/slack/slack-client.mjs +0 -1
- package/dist/common/base/base.app.d.ts +3 -3
- package/dist/common/base/base.app.mjs +0 -1
- package/dist/common/base/base.entity.d.ts +4 -16
- package/dist/common/base/base.entity.js +11 -39
- package/dist/common/base/base.entity.mjs +11 -40
- package/dist/common/base/base.use-case.d.ts +1 -7
- package/dist/common/base/base.use-case.mjs +0 -1
- package/dist/common/base/current-session.mjs +0 -1
- package/dist/common/base/current-user.mjs +0 -1
- package/dist/common/base/share.mjs +0 -1
- package/dist/common/base/utils/index.d.ts +1 -2
- package/dist/common/base/utils/index.js +2 -4
- package/dist/common/base/utils/index.mjs +1 -2
- package/dist/common/base/utils/is-plain-object.mjs +0 -1
- package/dist/common/base/utils/to-patch.d.ts +9 -0
- package/dist/common/base/utils/to-patch.js +46 -0
- package/dist/common/base/utils/to-patch.mjs +21 -0
- package/dist/common/constants/harness.mjs +0 -1
- package/dist/common/error/http-error.mjs +0 -1
- package/dist/common/error/reportError.mjs +0 -1
- package/dist/common/error/sentry-client.mjs +0 -1
- package/dist/common/helpers/escape-regex.mjs +0 -1
- package/dist/common/helpers/extract-json-from-text.mjs +0 -1
- package/dist/common/helpers/sanitize-string.mjs +0 -1
- package/dist/common/logger/pino.mjs +0 -1
- package/dist/common/repositories/mongo-db.client.mjs +0 -1
- package/dist/common/repositories/mongo-db.repository.d.ts +15 -4
- package/dist/common/repositories/mongo-db.repository.js +44 -15
- package/dist/common/repositories/mongo-db.repository.mjs +44 -16
- package/dist/common/repositories/scope.mjs +0 -1
- package/dist/common/utils/database-name.mjs +0 -1
- package/dist/common/utils/number-setting.mjs +0 -1
- package/dist/common/utils/secret-manager.mjs +0 -1
- package/dist/db/indexes/agent-actions.mjs +0 -1
- package/dist/db/indexes/agent-tasks.mjs +0 -1
- package/dist/db/indexes/agent-traces.mjs +0 -1
- package/dist/db/indexes/automation-runs.mjs +0 -1
- package/dist/db/indexes/automations.mjs +0 -1
- package/dist/db/indexes/chats.mjs +0 -1
- package/dist/db/indexes/index.js +3 -1
- package/dist/db/indexes/index.mjs +3 -2
- package/dist/db/indexes/llm-calls.mjs +0 -1
- package/dist/db/indexes/mcp-servers.js +2 -1
- package/dist/db/indexes/mcp-servers.mjs +2 -2
- package/dist/db/indexes/refresh-tokens.d.ts +2 -0
- package/dist/{common/decorators/mask-in-logs/index.js → db/indexes/refresh-tokens.js} +16 -5
- package/dist/db/indexes/refresh-tokens.mjs +9 -0
- package/dist/db/indexes/revoked-tokens.mjs +0 -1
- package/dist/db/indexes/workspace-items.mjs +0 -1
- package/dist/db/migrations/automations.mjs +0 -1
- package/dist/guardrails/guard.mjs +0 -1
- package/dist/guardrails/index.mjs +0 -1
- package/dist/guardrails/input/block-card.mjs +0 -1
- package/dist/guardrails/input/block-code.mjs +0 -1
- package/dist/guardrails/input/block-email.mjs +0 -1
- package/dist/guardrails/input/create-block-input-oversize.mjs +0 -1
- package/dist/guardrails/input/diagnostic-sanity.mjs +0 -1
- package/dist/guardrails/input/input-check.mjs +0 -1
- package/dist/harness/agent-loop.mjs +0 -1
- package/dist/harness/agent-state.mjs +0 -1
- package/dist/harness/agent.d.ts +1 -3
- package/dist/harness/agent.js +29 -23
- package/dist/harness/agent.mjs +29 -24
- package/dist/harness/native-tools.mjs +0 -1
- package/dist/harness/skills/approval-request.mjs +0 -1
- package/dist/harness/skills/autonomous-answer.mjs +0 -1
- package/dist/harness/skills/confirmation-gate.mjs +0 -1
- package/dist/harness/skills/mcp-change-review.mjs +0 -1
- package/dist/harness/tool-catalog.mjs +0 -1
- package/dist/harness/tool-pipeline.mjs +0 -1
- package/dist/harness/utils/activity.mjs +0 -1
- package/dist/harness/utils/describe-shape.mjs +0 -1
- package/dist/harness/utils/grounding.mjs +0 -1
- package/dist/harness/utils/rank-tools-by-keywords.mjs +0 -1
- package/dist/harness/workspace.js +7 -7
- package/dist/harness/workspace.mjs +7 -8
- package/dist/loops/agi/loop.mjs +0 -1
- package/dist/loops/agi/skills/reasoning-engine.mjs +0 -1
- package/dist/loops/shared/skills/fast-responder.mjs +0 -1
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +3 -1
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/refresh-token.entity.d.ts +25 -0
- package/dist/services/authentication/entities/refresh-token.entity.js +75 -0
- package/dist/services/authentication/entities/refresh-token.entity.mjs +51 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -1
- package/dist/services/authentication/helpers/auth-config.d.ts +9 -0
- package/dist/services/authentication/helpers/auth-config.js +36 -0
- package/dist/services/authentication/helpers/auth-config.mjs +12 -0
- package/dist/services/authentication/helpers/session-tokens.d.ts +16 -0
- package/dist/services/authentication/helpers/session-tokens.js +60 -0
- package/dist/services/authentication/helpers/session-tokens.mjs +35 -0
- package/dist/services/authentication/helpers/tokens.d.ts +43 -0
- package/dist/services/authentication/helpers/tokens.js +113 -0
- package/dist/services/authentication/helpers/tokens.mjs +71 -0
- package/dist/services/authentication/index.d.ts +3 -0
- package/dist/services/authentication/index.js +23 -0
- package/dist/services/authentication/index.mjs +11 -0
- package/dist/services/authentication/module.d.ts +12 -3
- package/dist/services/authentication/module.js +40 -7
- package/dist/services/authentication/module.mjs +34 -7
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/authentication/repositories/index.js +3 -1
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/refresh-token.repository.d.ts +10 -0
- package/dist/services/authentication/repositories/refresh-token.repository.js +60 -0
- package/dist/services/authentication/repositories/refresh-token.repository.mjs +36 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +3 -15
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +3 -10
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +12 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +40 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +43 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +19 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +40 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +6 -8
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +4 -18
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +4 -13
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +18 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +49 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +25 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.js +48 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/login.use-case.d.ts +11 -11
- package/dist/services/authentication/use-cases/login.use-case.js +18 -54
- package/dist/services/authentication/use-cases/login.use-case.mjs +17 -38
- package/dist/services/authentication/use-cases/logout.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/logout.use-case.js +48 -0
- package/dist/services/authentication/use-cases/logout.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/refresh.use-case.d.ts +23 -0
- package/dist/services/authentication/use-cases/refresh.use-case.js +84 -0
- package/dist/services/authentication/use-cases/refresh.use-case.mjs +60 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.js +61 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.mjs +37 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +4 -6
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +12 -26
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +10 -19
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +16 -0
- package/dist/services/automations/entities/automation-run.entity.mjs +0 -1
- package/dist/services/automations/entities/automation.entity.d.ts +1 -0
- package/dist/services/automations/entities/automation.entity.js +2 -1
- package/dist/services/automations/entities/automation.entity.mjs +2 -2
- package/dist/services/automations/entities/recurrence.mjs +0 -1
- package/dist/services/automations/entities/trigger.mjs +0 -1
- package/dist/services/automations/module.d.ts +0 -1
- package/dist/services/automations/module.js +20 -22
- package/dist/services/automations/module.mjs +20 -23
- package/dist/services/automations/repositories/automation-run.repository.js +7 -22
- package/dist/services/automations/repositories/automation-run.repository.mjs +7 -17
- package/dist/services/automations/repositories/automation.repository.js +25 -39
- package/dist/services/automations/repositories/automation.repository.mjs +25 -34
- package/dist/services/automations/runner/automation-runner.js +9 -12
- package/dist/services/automations/runner/automation-runner.mjs +9 -13
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +5 -19
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-due-automations.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/create-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -22
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/finish-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +5 -19
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +7 -9
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +6 -20
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +6 -15
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +3 -15
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +3 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +8 -23
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +8 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +4 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +4 -13
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +8 -21
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +9 -17
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +8 -22
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +12 -27
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +12 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +7 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +7 -17
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/update-automation.use-case.js +10 -24
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +10 -19
- package/dist/services/automations/utils/automation-event-error.mjs +0 -1
- package/dist/services/automations/utils/automation-fields.mjs +0 -1
- package/dist/services/automations/utils/event-message.mjs +0 -1
- package/dist/services/automations/utils/event-token.d.ts +1 -2
- package/dist/services/automations/utils/event-token.js +9 -35
- package/dist/services/automations/utils/event-token.mjs +9 -25
- package/dist/services/automations/utils/next-run.mjs +0 -1
- package/dist/services/automations/utils/open-run.mjs +0 -1
- package/dist/services/automations/utils/previous-run.js +1 -1
- package/dist/services/automations/utils/previous-run.mjs +1 -2
- package/dist/services/automations/utils/runner-scope.mjs +0 -1
- package/dist/services/automations/utils/settings.mjs +0 -1
- package/dist/services/chats/entities/chat-message.entity.mjs +0 -1
- package/dist/services/chats/entities/chat-settings.entity.mjs +0 -1
- package/dist/services/chats/entities/chat.entity.d.ts +1 -0
- package/dist/services/chats/entities/chat.entity.js +3 -2
- package/dist/services/chats/entities/chat.entity.mjs +3 -3
- package/dist/services/chats/module.d.ts +0 -1
- package/dist/services/chats/module.js +5 -7
- package/dist/services/chats/module.mjs +5 -8
- package/dist/services/chats/repositories/chat.repository.js +5 -20
- package/dist/services/chats/repositories/chat.repository.mjs +5 -15
- package/dist/services/chats/use-cases/create-chat.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/create-chat.use-case.js +5 -19
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -22
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +8 -17
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +6 -20
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/interrupt-execution.use-case.js +6 -20
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/update-chat.use-case.d.ts +5 -6
- package/dist/services/chats/use-cases/update-chat.use-case.js +8 -26
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +8 -21
- package/dist/services/chats/utils/deprecated-activity.mjs +0 -1
- package/dist/services/llmcalls/entities/llmcall.entity.mjs +0 -1
- package/dist/services/llmcalls/module.d.ts +0 -1
- package/dist/services/llmcalls/module.js +4 -6
- package/dist/services/llmcalls/module.mjs +4 -7
- package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -20
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +5 -15
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -22
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +8 -17
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +6 -20
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +6 -15
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -21
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +7 -16
- package/dist/services/llmcalls/utils/usage-periods.mjs +0 -1
- package/dist/services/llmcalls/utils/usage-totals.mjs +0 -1
- package/dist/services/mcp-servers/admin/index.d.ts +1 -0
- package/dist/{common/decorators → services/mcp-servers/admin}/index.js +4 -4
- package/dist/services/mcp-servers/admin/index.mjs +1 -0
- package/dist/services/mcp-servers/admin/module.d.ts +10 -0
- package/dist/services/mcp-servers/admin/module.js +55 -0
- package/dist/services/mcp-servers/admin/module.mjs +27 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +50 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +26 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +44 -0
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +20 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +12 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +41 -0
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +17 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +16 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +42 -0
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +18 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +13 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +59 -0
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +35 -0
- package/dist/services/mcp-servers/entities/mcp-manifest.mjs +0 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +10 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.js +28 -3
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +28 -4
- package/dist/services/mcp-servers/internal.d.ts +7 -0
- package/dist/{common/base/utils/flatten-object.js → services/mcp-servers/internal.js} +9 -22
- package/dist/services/mcp-servers/internal.mjs +8 -0
- package/dist/services/mcp-servers/module.d.ts +0 -1
- package/dist/services/mcp-servers/module.js +8 -10
- package/dist/services/mcp-servers/module.mjs +8 -11
- package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +8 -0
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +28 -24
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +29 -20
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +5 -21
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -16
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -21
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +7 -16
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -22
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +8 -17
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +7 -19
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +7 -14
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +10 -26
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +10 -21
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -23
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +9 -18
- package/dist/services/tasks/entities/agent-action.entity.mjs +0 -1
- package/dist/services/tasks/entities/agent-task.entity.mjs +0 -1
- package/dist/services/tasks/module.d.ts +0 -1
- package/dist/services/tasks/module.js +7 -9
- package/dist/services/tasks/module.mjs +7 -10
- package/dist/services/tasks/repositories/agent-action.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-action.repository.mjs +5 -16
- package/dist/services/tasks/repositories/agent-task.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-task.repository.mjs +5 -16
- package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-action.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +5 -19
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-action.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +6 -15
- package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-task.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +6 -15
- package/dist/services/traces/entities/agent-trace-entry.entity.mjs +0 -1
- package/dist/services/traces/module.d.ts +0 -1
- package/dist/services/traces/module.js +2 -4
- package/dist/services/traces/module.mjs +2 -5
- package/dist/services/traces/repositories/agent-trace.repository.js +3 -15
- package/dist/services/traces/repositories/agent-trace.repository.mjs +3 -10
- package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +6 -8
- package/dist/services/traces/use-cases/create-agent-traces.use-case.js +5 -19
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +5 -14
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +6 -6
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +5 -19
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +5 -14
- package/dist/services/users/entities/user-acquisition.js +2 -2
- package/dist/services/users/entities/user-acquisition.mjs +2 -3
- package/dist/services/users/entities/user-country.js +2 -2
- package/dist/services/users/entities/user-country.mjs +2 -3
- package/dist/services/users/entities/user-currency.js +2 -2
- package/dist/services/users/entities/user-currency.mjs +2 -3
- package/dist/services/users/entities/user-default-model.js +2 -2
- package/dist/services/users/entities/user-default-model.mjs +2 -3
- package/dist/services/users/entities/user-email.value-object.mjs +0 -1
- package/dist/services/users/entities/user-language.js +2 -2
- package/dist/services/users/entities/user-language.mjs +2 -3
- package/dist/services/users/entities/user-marketing.js +2 -2
- package/dist/services/users/entities/user-marketing.mjs +2 -3
- package/dist/services/users/entities/user-notification-preferences.mjs +0 -1
- package/dist/services/users/entities/user-password.value-object.mjs +0 -1
- package/dist/services/users/entities/user-permissions.mjs +0 -1
- package/dist/services/users/entities/user-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-schedule.mjs +0 -1
- package/dist/services/users/entities/user-timezone.js +2 -2
- package/dist/services/users/entities/user-timezone.mjs +2 -3
- package/dist/services/users/entities/user.entity.d.ts +1 -0
- package/dist/services/users/entities/user.entity.js +9 -22
- package/dist/services/users/entities/user.entity.mjs +9 -17
- package/dist/services/users/module.d.ts +2 -1
- package/dist/services/users/module.js +12 -7
- package/dist/services/users/module.mjs +11 -8
- package/dist/services/users/repositories/user.repository.d.ts +2 -0
- package/dist/services/users/repositories/user.repository.js +11 -20
- package/dist/services/users/repositories/user.repository.mjs +11 -15
- package/dist/services/users/use-cases/change-password.use-case.d.ts +15 -0
- package/dist/services/users/use-cases/change-password.use-case.js +52 -0
- package/dist/services/users/use-cases/change-password.use-case.mjs +28 -0
- package/dist/services/users/use-cases/create-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/create-user.use-case.js +5 -19
- package/dist/services/users/use-cases/create-user.use-case.mjs +5 -14
- package/dist/services/users/use-cases/delete-user.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/delete-user.use-case.js +8 -22
- package/dist/services/users/use-cases/delete-user.use-case.mjs +8 -17
- package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/get-user-by-id.use-case.js +6 -20
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +6 -15
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +5 -19
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +5 -14
- package/dist/services/users/use-cases/update-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/update-user.use-case.js +9 -22
- package/dist/services/users/use-cases/update-user.use-case.mjs +9 -17
- package/dist/services/users/utils/default-model.mjs +0 -1
- package/dist/services/workspaces/entities/workspace-item.entity.mjs +0 -1
- package/dist/services/workspaces/module.d.ts +0 -1
- package/dist/services/workspaces/module.js +5 -7
- package/dist/services/workspaces/module.mjs +5 -8
- package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -20
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +5 -15
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +6 -8
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +7 -21
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +7 -16
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +6 -20
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -15
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +5 -14
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -24
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +10 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +5 -14
- package/dist/skills/call-modes.mjs +0 -1
- package/dist/skills/runtime-context.mjs +0 -1
- package/dist/skills/shared/shared-rules.mjs +0 -1
- package/dist/skills/skill.js +1 -2
- package/dist/skills/skill.mjs +1 -3
- package/dist/tools/core/call-ai/call-ai.skill.mjs +0 -1
- package/dist/tools/core/call-ai/call-ai.tool.mjs +0 -1
- package/dist/tools/core/slack/send-slack-message.tool.mjs +0 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +0 -1
- package/dist/tools/tool.mjs +0 -1
- package/docs/agent.md +1 -1
- package/docs/authentication.md +95 -16
- package/docs/authorization.md +1 -1
- package/docs/automations.md +29 -11
- package/docs/chats.md +1 -1
- package/docs/configuration.md +1 -2
- package/docs/integration-guide.md +2 -2
- package/docs/mcp-servers.md +85 -2
- package/docs/usage.md +5 -5
- package/docs/users.md +1 -1
- package/examples/authentication/login.ts +1 -1
- package/examples/automations/create-automation.ts +1 -1
- package/examples/automations/create-event-automation.ts +2 -2
- package/examples/automations/list-automation-runs.ts +2 -2
- package/examples/automations/list-automations.ts +1 -1
- package/examples/automations/preview-automation-runs.ts +1 -1
- package/examples/automations/receive-automation-event.ts +1 -1
- package/examples/automations/revoke-automation-event-token.ts +2 -2
- package/examples/automations/run-automation-worker.ts +8 -0
- package/examples/automations/update-automation.ts +2 -2
- package/examples/chats/get-chat-by-id.ts +2 -2
- package/examples/chats/list-autonomous-chats.ts +1 -1
- package/examples/chats/list-chats.ts +1 -1
- package/examples/mcps/create-mcp.ts +1 -0
- package/examples/mcps/decide-mcp.ts +3 -3
- package/examples/mcps/internal-mcp-admin.ts +43 -0
- package/examples/mcps/internal-mcp.ts +14 -3
- package/examples/mcps/list-all-mcps.ts +1 -1
- package/examples/mcps/update-mcp.ts +1 -1
- package/examples/mcps/verify-mcp.ts +1 -1
- package/examples/usage/get-chat-usage.ts +2 -2
- package/examples/usage/get-message-usage.ts +2 -2
- package/examples/usage/get-usage-stats-by-range.ts +1 -1
- package/examples/usage/get-usage-stats.ts +3 -3
- package/examples/users/set-default-model.ts +1 -1
- package/package.json +6 -4
- package/dist/chunk-CF3WOMB3.mjs +0 -16
- package/dist/common/base/utils/delete-empty-fields.d.ts +0 -1
- package/dist/common/base/utils/delete-empty-fields.js +0 -66
- package/dist/common/base/utils/delete-empty-fields.mjs +0 -43
- package/dist/common/base/utils/flatten-object.d.ts +0 -1
- package/dist/common/base/utils/flatten-object.mjs +0 -22
- package/dist/common/decorators/index.d.ts +0 -1
- package/dist/common/decorators/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
- package/dist/common/decorators/mask-in-logs/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +0 -2
- package/dist/common/decorators/mask-in-logs/mask-in-logs.js +0 -53
- package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +0 -29
package/dist/skills/skill.js
CHANGED
|
@@ -23,7 +23,6 @@ __export(skill_exports, {
|
|
|
23
23
|
SkillMode: () => import_call_modes2.SkillMode
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(skill_exports);
|
|
26
|
-
var import_tsyringe = require("tsyringe");
|
|
27
26
|
var import_helpers = require("../common/helpers/index.js");
|
|
28
27
|
var import_llm_client = require("../clients/llm/llm-client.js");
|
|
29
28
|
var import_logger = require("../common/logger/index.js");
|
|
@@ -58,7 +57,7 @@ class Skill {
|
|
|
58
57
|
if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
|
|
59
58
|
if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
|
|
60
59
|
try {
|
|
61
|
-
const llmClient =
|
|
60
|
+
const llmClient = new import_llm_client.LLMClient();
|
|
62
61
|
const context = {
|
|
63
62
|
...(0, import_runtime_context.buildRuntimeContext)({ currentUser, currentSession, chat }),
|
|
64
63
|
...contextInjection
|
package/dist/skills/skill.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "../chunk-CF3WOMB3.mjs";
|
|
2
|
-
import { container } from "tsyringe";
|
|
3
1
|
import { extractJSON } from "../common/helpers/index.js";
|
|
4
2
|
import { LLMClient } from "../clients/llm/llm-client.js";
|
|
5
3
|
import { Logger } from "../common/logger/index.js";
|
|
@@ -34,7 +32,7 @@ class Skill {
|
|
|
34
32
|
if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
|
|
35
33
|
if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
|
|
36
34
|
try {
|
|
37
|
-
const llmClient =
|
|
35
|
+
const llmClient = new LLMClient();
|
|
38
36
|
const context = {
|
|
39
37
|
...buildRuntimeContext({ currentUser, currentSession, chat }),
|
|
40
38
|
...contextInjection
|
package/dist/tools/tool.mjs
CHANGED
package/docs/agent.md
CHANGED
|
@@ -72,7 +72,7 @@ Omit `chatId` to start a brand-new chat. Pass an existing `chatId` to continue a
|
|
|
72
72
|
|
|
73
73
|
`currentSession` is optional. It carries device, location and locale, which skills use to answer in the right time zone and language.
|
|
74
74
|
|
|
75
|
-
`mcpTokens` is optional. It gives the token of the user to each [internal MCP server](mcp-servers.md#internal-mcp-servers), by name. It is never saved.
|
|
75
|
+
`mcpTokens` is optional. It gives the token of the user to each [internal MCP server](mcp-servers.md#internal-mcp-servers), by name. It is never saved. In an [autonomous run](#autonomous-mode) with no token for a server, the `autonomousToken` of that server is used, see [automations](automations.md#internal-mcp-servers-in-an-automation).
|
|
76
76
|
|
|
77
77
|
## Autonomous mode
|
|
78
78
|
|
package/docs/authentication.md
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
# Authentication
|
|
2
2
|
|
|
3
|
-
`openloops`
|
|
3
|
+
`openloops` logs a user in against its own user records and issues the tokens of the session. It also issues the tokens to reset a password and the tokens of [event automations](automations.md#the-token), all with the same convention. Verifying the token on each request and deciding who may call what is up to your backend, with `verifySessionToken` to read it.
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
|
-
import { login, revokeToken, isTokenRevoked } from 'openloops/authentication'
|
|
6
|
+
import { login, refreshSession, logout, issuePasswordResetToken, resetPassword, revokeUserSessions, revokeToken, isTokenRevoked, verifySessionToken } from 'openloops/authentication'
|
|
7
|
+
import { changePassword } from 'openloops/users'
|
|
7
8
|
```
|
|
8
9
|
|
|
10
|
+
`JWT_SECRET` must be set. See [configuration](configuration.md).
|
|
11
|
+
|
|
12
|
+
**Rate limit is yours.** `openloops` does not limit the attempts to log in, to ask for a reset or to use a token. Your backend must do it before it calls `login` and `issuePasswordResetToken`, by account and by address, and answer 429 when the limit is reached.
|
|
13
|
+
|
|
14
|
+
## The tokens
|
|
15
|
+
|
|
16
|
+
Every token is a JWT signed with `HS256` and `JWT_SECRET`, and carries the same claims:
|
|
17
|
+
|
|
18
|
+
| Claim | Value |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `iss` | `openloops`. A token without it, or with another one, is refused. |
|
|
21
|
+
| `aud` | What the token is for: `session`, `password-reset` or `automation-event`. A token is only valid for its own audience. |
|
|
22
|
+
| `sub` | The id of the user, or the id of the automation for an event token. |
|
|
23
|
+
| `jti` | A unique id, only in the tokens that can be revoked one by one: reset and event tokens. |
|
|
24
|
+
| `exp` | When it stops working. |
|
|
25
|
+
|
|
26
|
+
| Token | Audience | Duration | Extra claims |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| Access of a session | `session` | 1 hour | `email`, `firstName`, `lastName`, `sid` (the id of the session) |
|
|
29
|
+
| Reset of the password | `password-reset` | 15 minutes | `jti` |
|
|
30
|
+
| Event of an automation | `automation-event` | The one you choose, or none | `jti`, `v` |
|
|
31
|
+
|
|
32
|
+
The refresh token is not a JWT: it is a random string, and only its hash is stored.
|
|
33
|
+
|
|
9
34
|
## Logging in
|
|
10
35
|
|
|
11
36
|
```typescript
|
|
@@ -16,42 +41,96 @@ const result = await login({
|
|
|
16
41
|
},
|
|
17
42
|
})
|
|
18
43
|
|
|
19
|
-
result.
|
|
20
|
-
result.
|
|
44
|
+
result.accessToken
|
|
45
|
+
result.refreshToken
|
|
46
|
+
result.expiresIn
|
|
47
|
+
result.refreshExpiresAt
|
|
48
|
+
result.user
|
|
21
49
|
```
|
|
22
50
|
|
|
23
|
-
- `
|
|
24
|
-
- Tokens last 1 hour for admins and 7 days for everyone else.
|
|
51
|
+
- `accessToken` lasts 1 hour. `refreshToken` lasts 30 days for a user and 7 days for an admin, and a session cannot be extended beyond 90 days (7 for an admin), no matter how often it is refreshed.
|
|
25
52
|
- `user` is the user record without the password.
|
|
26
|
-
-
|
|
53
|
+
- A missing field fails with 400. An unknown user and a wrong password fail with the same 401, so the answer does not tell which accounts exist.
|
|
27
54
|
|
|
28
|
-
|
|
55
|
+
## Keeping the session
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const next = await refreshSession({ refreshToken })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- It gives a new access token and a new refresh token, and the old refresh token cannot be used again. All of them belong to one session.
|
|
62
|
+
- A refresh token that was used is accepted again for 10 seconds, to survive a retry of the client. Later than that, it is taken as stolen: the whole session is closed and the next refresh fails with 401.
|
|
63
|
+
- It fails with 401 for an unknown, expired or revoked token, and when the user no longer exists.
|
|
64
|
+
- Two refreshes at the same time with the same token do not create two sessions.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
await logout({ refreshToken })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Closes the session of that refresh token. An unknown or missing token is ignored.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
await revokeUserSessions({ userId, now: new Date(), exceptFamilyId })
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Closes every session of the user, except the one you name. `changePassword` and `resetPassword` do it for you.
|
|
29
77
|
|
|
30
78
|
## From a token to a `CurrentUser`
|
|
31
79
|
|
|
32
|
-
|
|
80
|
+
Your backend reads the access token, and builds the `CurrentUser` that every other call needs:
|
|
33
81
|
|
|
34
82
|
```typescript
|
|
83
|
+
import { verifySessionToken } from 'openloops/authentication'
|
|
35
84
|
import { CurrentUser } from 'openloops/base'
|
|
36
85
|
|
|
37
|
-
const
|
|
86
|
+
const claims = verifySessionToken(token)
|
|
87
|
+
const currentUser = await CurrentUser.asyncFromDB(claims.userId)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`verifySessionToken` throws a `TokenError` whose `reason` is `invalid` or `expired`. It refuses a token of another audience, so a reset token or an event token cannot be used as a session. See [users](users.md).
|
|
91
|
+
|
|
92
|
+
## Resetting a password
|
|
93
|
+
|
|
94
|
+
`openloops` does not send emails. It issues the token, and your backend sends the link:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const issued = await issuePasswordResetToken({ payload: { emailOrUsername } })
|
|
98
|
+
|
|
99
|
+
if (issued) await sendEmail(issued.user.email, `https://example.com/reset?token=${issued.token}`)
|
|
38
100
|
```
|
|
39
101
|
|
|
40
|
-
|
|
102
|
+
- It answers `null` when the user does not exist. Answer the same to the client in both cases, so nobody can learn which accounts exist.
|
|
103
|
+
- The token lasts 15 minutes and works once.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
await resetPassword({ token, password })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- It fails with 401 for a token that is invalid, expired, already used, or that is not a reset token, and with 400 if there is no password.
|
|
110
|
+
- It changes the password and closes every session of the user.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
await changePassword({ id, password, sessionId, currentUser })
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For a user that changes their own password while logged in. It closes the other sessions and keeps the one in `sessionId` (the `sessionId` that `verifySessionToken` gives). `updateUser` refuses a `password`: this is the only way to change it.
|
|
41
117
|
|
|
42
118
|
## Revoked tokens
|
|
43
119
|
|
|
44
120
|
A signed token cannot be taken back, so `openloops` keeps a list of the ids (`jti`) of the tokens that must stop working, in the collection `revoked_tokens`.
|
|
45
121
|
|
|
46
122
|
```typescript
|
|
47
|
-
await revokeToken({ payload: { jti, audience: 'automation-event', subject: automationId, expiresAt }
|
|
123
|
+
const isFirstTime = await revokeToken({ payload: { jti, audience: 'automation-event', subject: automationId, expiresAt } })
|
|
48
124
|
|
|
49
|
-
const
|
|
125
|
+
const data = await isTokenRevoked({ jti })
|
|
50
126
|
|
|
51
127
|
data.revoked
|
|
52
128
|
```
|
|
53
129
|
|
|
54
|
-
- Revoking the same `jti` twice does nothing
|
|
55
|
-
-
|
|
56
|
-
- The
|
|
130
|
+
- Revoking the same `jti` twice does nothing and answers `false`. `expiresAt` is optional: when it is set, the entry is deleted by itself on that date, which is when the token would have stopped working anyway.
|
|
131
|
+
- Reset tokens use it so they work once, and event tokens use it through `revokeAutomationEventToken`.
|
|
132
|
+
- The access token of a session has no `jti`: to cut a session, close it with `logout` or `revokeUserSessions`. The access token still works until it expires, at most one hour.
|
|
133
|
+
|
|
134
|
+
## Collections
|
|
57
135
|
|
|
136
|
+
`refresh_tokens` and `revoked_tokens` are created by `ensureIndexes` (see [configuration](configuration.md)). If another backend shares the database and uses the same convention, both read and write the same documents.
|
package/docs/authorization.md
CHANGED
|
@@ -45,7 +45,7 @@ await createAutomation({ payload: { ...payload, ownerId: otherUserId }, scope: S
|
|
|
45
45
|
|
|
46
46
|
## What changes in your endpoints
|
|
47
47
|
|
|
48
|
-
- A record that is not the user's is answered as if it did not exist. The functions that update or delete throw a 404 `HttpError` with the message `{{resource_not_found}}`,
|
|
48
|
+
- A record that is not the user's is answered as if it did not exist. The functions that update or delete throw a 404 `HttpError` with the message `{{resource_not_found}}`, and the getters return `null` or throw the same 404. Nobody can learn that an id exists by getting a 403.
|
|
49
49
|
- A call without `currentUser` and without `scope` fails with 401, it does not read everything.
|
|
50
50
|
- You do not need to load the record to check `ownerId` before calling a function that takes an id.
|
|
51
51
|
|
package/docs/automations.md
CHANGED
|
@@ -41,7 +41,7 @@ const result = await createAutomation({
|
|
|
41
41
|
currentUser,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
result.
|
|
44
|
+
result.triggers.schedule.nextRunAt
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
| Field | Required | What it is |
|
|
@@ -101,7 +101,7 @@ The recurrence of a `schedule` trigger is stored as a structured value, so a scr
|
|
|
101
101
|
### Previewing
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
const
|
|
104
|
+
const data = await previewAutomationRuns({
|
|
105
105
|
recurrence: { type: 'weekly', days: [1, 5], time: '08:00' },
|
|
106
106
|
timezone: 'America/New_York',
|
|
107
107
|
count: 5,
|
|
@@ -145,7 +145,7 @@ await deleteAutomation({ id, currentUser })
|
|
|
145
145
|
An automation with an event trigger runs when another system sends it an event, for example an alarm of AWS that reaches a Lambda, which calls your backend. The event becomes a run in a queue and the runner executes it as soon as it can.
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
|
-
const
|
|
148
|
+
const automation = await createAutomation({
|
|
149
149
|
payload: {
|
|
150
150
|
name: 'Cost anomaly analysis',
|
|
151
151
|
instructions: 'Find the cause of the cost alert in AWS and send a summary to the channel #costs',
|
|
@@ -154,7 +154,7 @@ const { data: automation } = await createAutomation({
|
|
|
154
154
|
currentUser,
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
-
const
|
|
157
|
+
const data = await issueAutomationEventToken({ id: String(automation._id), expiresIn: '90d', currentUser })
|
|
158
158
|
|
|
159
159
|
data.token
|
|
160
160
|
data.expiresAt
|
|
@@ -167,7 +167,7 @@ import { AutomationEventError, receiveAutomationEvent } from 'openloops/automati
|
|
|
167
167
|
|
|
168
168
|
app.post('/automations/events/:automationId', async (req, res) => {
|
|
169
169
|
try {
|
|
170
|
-
const
|
|
170
|
+
const data = await receiveAutomationEvent({
|
|
171
171
|
automationId: req.params.automationId,
|
|
172
172
|
token: req.headers.authorization?.replace(/^Bearer /, ''),
|
|
173
173
|
payload: req.body,
|
|
@@ -215,6 +215,7 @@ The token is a JWT signed with `JWT_SECRET`. It is not stored: the owner can ask
|
|
|
215
215
|
|
|
216
216
|
| Claim | Value |
|
|
217
217
|
| --- | --- |
|
|
218
|
+
| `iss` | `openloops`, like every token of the package (see [authentication](authentication.md#the-tokens)). |
|
|
218
219
|
| `aud` | `automation-event`. A session token of a user is refused, and this one does not log anybody in. |
|
|
219
220
|
| `sub` | The id of the automation. It must be the one of the URL. |
|
|
220
221
|
| `v` | The `eventTokenVersion` of the automation when the token was issued. |
|
|
@@ -319,13 +320,30 @@ A new `Agent` is created for every run, so the options are the same but nothing
|
|
|
319
320
|
|
|
320
321
|
### Internal MCP servers in an automation
|
|
321
322
|
|
|
322
|
-
An automation runs without the session of its owner, so there is no token of theirs to send to your [internal MCP servers](mcp-servers.md#internal-mcp-servers).
|
|
323
|
+
An automation runs without the session of its owner, so there is no token of theirs to send to your [internal MCP servers](mcp-servers.md#internal-mcp-servers). Each internal server can declare an `autonomousToken`, the token of a service account that is used only in autonomous runs, such as the ones of the runner, when the run brings no token for that server:
|
|
323
324
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
```typescript
|
|
326
|
+
const runner = createAutomationRunner({
|
|
327
|
+
agent: {
|
|
328
|
+
loop: new AgiLoop(),
|
|
329
|
+
internalMcps: [
|
|
330
|
+
{
|
|
331
|
+
name: 'budget',
|
|
332
|
+
url: 'https://api.example.com/mcp',
|
|
333
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
334
|
+
autonomousToken: process.env.BUDGET_SERVICE_TOKEN,
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
})
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
- `{{token}}` is replaced with the `autonomousToken` and the agent sends the id of the owner of the automation in the header `X-User-Id`, so your MCP server knows on whose behalf it acts.
|
|
342
|
+
- Your MCP server must accept `X-User-Id` only together with that service token. Never trust it on a request that carries the token of a user.
|
|
343
|
+
- The header is added only in autonomous runs and only to internal servers that use `{{token}}`. It replaces any `X-User-Id` you configured. It is never sent to the servers added by the user.
|
|
344
|
+
- An interactive run never uses the `autonomousToken`. A server without one is unavailable in the automations that need a token, and the run continues without it.
|
|
345
|
+
- Each server has its own token, so two servers can use different service accounts. A server that must use a service account in every run, also in chats, does not need this: write the token in the header (for example `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U`).
|
|
346
|
+
- This field is temporary. It will go away when the integrations let the runner get the token of the owner.
|
|
329
347
|
|
|
330
348
|
### Running by hand
|
|
331
349
|
|
package/docs/chats.md
CHANGED
|
@@ -43,7 +43,7 @@ const result = await listChatsByUser({
|
|
|
43
43
|
})
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Sorted by last update, newest first. Defaults to page 1 and 10 chats. The result has `
|
|
46
|
+
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.
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
const autonomous = await listChatsByUser({ executionMode: 'autonomous', currentUser })
|
package/docs/configuration.md
CHANGED
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
| `SECRET_MANAGER_KEY` | yes | Key used to decrypt values that start with `ENC:`. The library throws when it loads without it. |
|
|
11
11
|
| `ANTHROPIC_API_KEY` | for the default model | API key of the default provider, `anthropic`. |
|
|
12
12
|
| `OPENAI_API_KEY`, `GEMINI_API_KEY` | for those providers | API keys of the other providers you choose per chat. |
|
|
13
|
-
| `JWT_SECRET` | for `login` and for event automations | Secret that signs the tokens of the
|
|
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). |
|
|
14
14
|
| `SERPER_API_KEY` | for `webSearchTool` | See [tools](tools.md#built-in-tools). |
|
|
15
15
|
| `SLACK_BOT_TOKEN` | for `sendSlackMessageTool` | See [tools](tools.md#built-in-tools). |
|
|
16
|
-
| `INTERNAL_MCP_TOKEN` | for internal MCP servers in automations | Token sent to the internal MCP servers when an automation runs without the session of its owner. See [automations](automations.md#internal-mcp-servers-in-a-automation). |
|
|
17
16
|
| `AUTOMATIONS_POLL_INTERVAL_MS` | no | How often the runner of [automations](automations.md) checks what is due, in milliseconds. Defaults to `60000`. |
|
|
18
17
|
| `AUTOMATIONS_LEASE_MS` | no | How long an automation stays locked while it runs, in milliseconds. Defaults to `600000`. |
|
|
19
18
|
| `AUTOMATIONS_MAX_QUEUED_RUNS` | no | How many events of one automation can wait to run. The next ones are recorded as skipped. Defaults to `10`. Read by the endpoint that receives the events. |
|
|
@@ -23,7 +23,7 @@ The package has no controllers: the authorization of every endpoint is the respo
|
|
|
23
23
|
|
|
24
24
|
The use cases check who owns every record, in the repository, with the `currentUser` you pass. Read [authorization](authorization.md) once.
|
|
25
25
|
|
|
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,
|
|
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
27
|
- A call without `currentUser` fails with 401. Your endpoint is still the one that authenticates the request and builds the `currentUser` from the token.
|
|
28
28
|
- An administrator acts on the records of other users only with `scope: Scope.asAdmin(currentUser)`, and a worker or a webhook with `Scope.system('reason')`. Never build a scope from a value that comes from a request.
|
|
29
29
|
|
|
@@ -44,7 +44,7 @@ The use cases check who owns every record, in the repository, with the `currentU
|
|
|
44
44
|
| Tokens of an event automation | `issueAutomationEventToken`, `revokeAutomationEventToken`, `rotateAutomationEventTokens` |
|
|
45
45
|
| History of runs | `listAutomationRunsByAutomation`, `listAutomationRunsByUser` |
|
|
46
46
|
| "Run now" | `runner.runNow({ automationId, currentUser })` |
|
|
47
|
-
| Sign in, users | `login`, `createUser`, `getUserById`, `updateUser`, `deleteUser` |
|
|
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
|
|
50
50
|
|
package/docs/mcp-servers.md
CHANGED
|
@@ -44,6 +44,7 @@ Creating a server connects to it once to read its manifest (tools and instructio
|
|
|
44
44
|
| Field | Meaning |
|
|
45
45
|
| --- | --- |
|
|
46
46
|
| `name`, `url`, `type`, `headers` | What you registered. |
|
|
47
|
+
| `environment` | Optional free text that says which environment the server belongs to (for example `staging` or `production`). It is only a label: the agent does not use it. A blank text removes it. |
|
|
47
48
|
| `trust` | `locked` (never approved, also the value of old records without one), `approved` or `blocked`. |
|
|
48
49
|
| `approvedHash` | Hash of the manifest the user approved. |
|
|
49
50
|
| `history` | The last 5 manifests the server has shown, newest first. The approved one is never dropped. |
|
|
@@ -118,7 +119,7 @@ Connects, reads the manifest and stores it in `history` if it is new, or stores
|
|
|
118
119
|
await decideMcpServerTrust({
|
|
119
120
|
id: mcpServerId,
|
|
120
121
|
decision: 'approve',
|
|
121
|
-
manifestHash: result.
|
|
122
|
+
manifestHash: result.history[0].hash,
|
|
122
123
|
currentUser,
|
|
123
124
|
})
|
|
124
125
|
|
|
@@ -158,6 +159,7 @@ const agent = new Agent({
|
|
|
158
159
|
Authorization: 'Bearer {{token}}',
|
|
159
160
|
'X-App': 'budget-agent',
|
|
160
161
|
},
|
|
162
|
+
autonomousToken: process.env.BUDGET_SERVICE_TOKEN,
|
|
161
163
|
},
|
|
162
164
|
],
|
|
163
165
|
})
|
|
@@ -173,13 +175,94 @@ await agent.run({
|
|
|
173
175
|
|
|
174
176
|
- `name` and `url` are required, and the name must be unique among the internal servers. `headers` is optional.
|
|
175
177
|
- `{{token}}` in a header value is replaced with `mcpTokens[name]` of the run. A header without the placeholder is sent as written, so the other headers are plain strings. If no header uses `{{token}}`, the server needs no token.
|
|
178
|
+
- `autonomousToken` is optional. It is the token of a service account, used instead of `mcpTokens[name]` only in an [autonomous run](agent.md#autonomous-mode) that brings no token for that server, and then the agent also sends the id of the user in `X-User-Id`. An interactive run never uses it. See [automations](automations.md#internal-mcp-servers-in-an-automation).
|
|
176
179
|
- The token lives only in memory during the run. Do not put it in `options`, which is saved in the chat. It is masked in the connection errors the agent logs.
|
|
177
180
|
- It is trusted: no approval is asked, the manifest is not reviewed or stored, and its tools are not marked as written by a third party. The tools still follow the rules of the tool pipeline, so a tool with `destructiveHint` asks the user before it runs.
|
|
178
181
|
- If the token of a server is missing for a run, or it cannot be reached, the agent leaves it out for that run, writes a trace and a log, and tells the model that the source is unavailable, so it says it could not access that information. The run does not fail. It does not tell the user the details, only that the source was not reachable.
|
|
179
182
|
- If a server of the user has the same name as an internal one, the one of the user is ignored for that run, so nobody can impersonate an internal server.
|
|
180
183
|
- The tools are named `<name>__<tool>`, like any other MCP tool.
|
|
181
184
|
|
|
182
|
-
In an automation there is no session of the user, so there is no token of theirs. See [automations](automations.md#internal-mcp-servers-in-
|
|
185
|
+
In an automation there is no session of the user, so there is no token of theirs. See [automations](automations.md#internal-mcp-servers-in-an-automation).
|
|
186
|
+
|
|
187
|
+
### Which token a server uses
|
|
188
|
+
|
|
189
|
+
There are three common setups. The difference is what the header says and whether the server has an `autonomousToken`.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const agent = new Agent({
|
|
193
|
+
loop: new AgiLoop(),
|
|
194
|
+
internalMcps: [
|
|
195
|
+
{
|
|
196
|
+
name: 'budget',
|
|
197
|
+
url: 'https://budget.example.com/mcp',
|
|
198
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'crm',
|
|
202
|
+
url: 'https://crm.example.com/mcp',
|
|
203
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
204
|
+
autonomousToken: process.env.CRM_SERVICE_TOKEN,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'catalog',
|
|
208
|
+
url: 'https://catalog.example.com/mcp',
|
|
209
|
+
headers: { Authorization: `Bearer ${process.env.CATALOG_SERVICE_TOKEN}` },
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
await agent.run({
|
|
215
|
+
input: { message: 'summarize my week' },
|
|
216
|
+
currentUser,
|
|
217
|
+
mcpTokens: { budget: sessionToken, crm: sessionToken },
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
| Server | Chat with `mcpTokens` | Automation (autonomous, no `mcpTokens`) |
|
|
222
|
+
| --- | --- | --- |
|
|
223
|
+
| `budget`: user token only | The token of the user. | Unavailable: there is no token and no `autonomousToken`. |
|
|
224
|
+
| `crm`: user token, and a service account for automations | The token of the user. | `CRM_SERVICE_TOKEN`, and the header `X-User-Id` with the owner of the automation. |
|
|
225
|
+
| `catalog`: always the service account | `CATALOG_SERVICE_TOKEN`, written in the header. | The same, without `X-User-Id`. |
|
|
226
|
+
|
|
227
|
+
- A chat never uses an `autonomousToken`. If `crm` is used in a chat and the request brings no token for it, the server is unavailable for that run.
|
|
228
|
+
- In `catalog` the credential is the same for every user and in every run. Use it only for data that is not specific to a user.
|
|
229
|
+
|
|
230
|
+
### Internal servers stored in the database
|
|
231
|
+
|
|
232
|
+
You can also manage the internal servers from a back office, without a deploy. They are stored in the same collection as the servers of the users, with `internal: true`, and the agent loads the enabled ones at the start of every run next to the ones declared in code. They behave the same way: trusted, no manifest review, no history, no notice of third party, destructive tools still ask.
|
|
233
|
+
|
|
234
|
+
They live in their own entry point, so the screens of the users never import them:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import {
|
|
238
|
+
createInternalMcp,
|
|
239
|
+
updateInternalMcp,
|
|
240
|
+
getInternalMcpById,
|
|
241
|
+
listInternalMcps,
|
|
242
|
+
deleteInternalMcp,
|
|
243
|
+
} from 'openloops/mcps/admin'
|
|
244
|
+
|
|
245
|
+
const mcp = await createInternalMcp({
|
|
246
|
+
payload: {
|
|
247
|
+
name: 'budget',
|
|
248
|
+
url: 'https://api.example.com/mcp',
|
|
249
|
+
headers: { Authorization: 'Bearer {{token}}' },
|
|
250
|
+
autonomousToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U',
|
|
251
|
+
},
|
|
252
|
+
currentUser: admin,
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
await updateInternalMcp({ id: mcp._id, payload: { enabled: false, __v: mcp.__v }, currentUser: admin })
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- Every function needs an admin as `currentUser` and answers 403 otherwise. The sub-route separates the code, the permission is what protects it.
|
|
259
|
+
- `name` and `url` are required, `type` is always `http`, `environment` and `autonomousToken` are optional and `enabled` defaults to `true`. A disabled server is not loaded. The name must be unique among the internal servers (409).
|
|
260
|
+
- A header with `{{token}}` works as in the declared ones: it uses `mcpTokens[name]` of the run, or its `autonomousToken` in an autonomous run. A header with the token written in it (for example `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjcm0uZXhhbXBsZS5jb20iLCJzdWIiOiJzdmMtb3Blbmxvb3BzLWNybSIsImF1ZCI6ImNybS1tY3AiLCJzY29wZSI6ImNybTpyZWFkIGNybTp3cml0ZSIsImlhdCI6MTc2MjIxNDQwMCwiZXhwIjoxNzkzNzUwNDAwfQ.YCtd8mv7RZpaZb3Z1aSl25MGP2QRWHc8RtA82MJOH7U`) is sent as it is and needs nothing from the run.
|
|
261
|
+
- Deleting is permanent. Internal servers have no owner, so they are not listed to any user.
|
|
262
|
+
- The normal functions (`getMcpServerById`, `updateMcpServer`, `deleteMcpServer`, `decideMcpServerTrust`, and the lists) never see them, not even for an admin, and `internal` and `enabled` in the payload of a user are ignored.
|
|
263
|
+
- If a server declared in code has the same name, the one in code wins. A server of a user with the same name as an internal one is ignored for that run.
|
|
264
|
+
- `headers` and `autonomousToken` are stored as written, like the headers of the servers of the users. Mask them in your controller before sending a record to a client.
|
|
265
|
+
- Run `ensureIndexes` after updating: it adds the unique index of the names of the internal servers.
|
|
183
266
|
|
|
184
267
|
## Tools of MCP servers
|
|
185
268
|
|
package/docs/usage.md
CHANGED
|
@@ -29,10 +29,10 @@ const chat = await getLLMUsageByChat({
|
|
|
29
29
|
`messageId` is the `answerId` of the assistant message, and everything the agent spent to produce that answer is added together. Both functions only count the calls of `currentUser`, and both return the same shape:
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
-
result.
|
|
32
|
+
result.summary
|
|
33
33
|
// { calls, input, output, cacheRead, cacheWrite, reasoning, totalTokens, totalCost }
|
|
34
34
|
|
|
35
|
-
result.
|
|
35
|
+
result.models
|
|
36
36
|
// [{ provider, model, calls, input, output, cacheRead, cacheWrite, reasoning, totalTokens, totalCost }]
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -77,13 +77,13 @@ Days and periods are calculated in the time zone of the user (UTC when the user
|
|
|
77
77
|
### The result
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
|
-
result.
|
|
80
|
+
result.summary
|
|
81
81
|
// { calls, totalTokens, totalCost }
|
|
82
82
|
|
|
83
|
-
result.
|
|
83
|
+
result.models
|
|
84
84
|
// [{ provider, model, calls, totalTokens, totalCost, tokensPercentage, costPercentage }]
|
|
85
85
|
|
|
86
|
-
result.
|
|
86
|
+
result.series
|
|
87
87
|
// [{ period, input, output, cacheRead, cacheWrite, reasoning, totalTokens, totalCost }]
|
|
88
88
|
```
|
|
89
89
|
|
package/docs/users.md
CHANGED
|
@@ -34,7 +34,7 @@ const result = await createUser({
|
|
|
34
34
|
})
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
`email` and `password` are required. Passwords are hashed before being stored and are never returned.
|
|
37
|
+
`email` and `password` are required. Passwords are hashed before being stored and are never returned. To change it later use `changePassword` (see [authentication](authentication.md#resetting-a-password)): `updateUser` refuses a `password`.
|
|
38
38
|
|
|
39
39
|
### The scope
|
|
40
40
|
|
|
@@ -11,7 +11,7 @@ async function loginExample () {
|
|
|
11
11
|
},
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
logger.info({ user: result.
|
|
14
|
+
logger.info({ user: result.user, accessToken: result.accessToken, refreshToken: result.refreshToken }, '[Demo] Logged in')
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
loginExample()
|
|
@@ -22,7 +22,7 @@ async function createSchedule () {
|
|
|
22
22
|
currentUser,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
logger.info({ id: result.
|
|
25
|
+
logger.info({ id: result._id, nextRunAt: result.triggers?.schedule?.nextRunAt }, '[Demo] Created automation')
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
createSchedule()
|
|
@@ -15,10 +15,10 @@ async function createEventAutomation () {
|
|
|
15
15
|
currentUser,
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
const id = String(created.
|
|
18
|
+
const id = String(created._id)
|
|
19
19
|
const issued = await issueAutomationEventToken({ id, expiresIn: '90d', currentUser })
|
|
20
20
|
|
|
21
|
-
logger.info({ id, token: issued.
|
|
21
|
+
logger.info({ id, token: issued.token, expiresAt: issued.expiresAt }, '[Demo] Created automation, send events to it with this token')
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
createEventAutomation()
|
|
@@ -12,7 +12,7 @@ async function listRunsOfAnAutomation () {
|
|
|
12
12
|
currentUser,
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
logger.info(result.
|
|
15
|
+
logger.info(result.items.map(run => ({ status: run.status, startedAt: run.startedAt, chatId: run.chatId, error: run.error })), '[Demo] Runs of the automation')
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async function listRunsThatNeedAttention () {
|
|
@@ -22,7 +22,7 @@ async function listRunsThatNeedAttention () {
|
|
|
22
22
|
const paused = await listAutomationRunsByUser({ status: 'paused', currentUser })
|
|
23
23
|
const failed = await listAutomationRunsByUser({ status: 'failed', currentUser })
|
|
24
24
|
|
|
25
|
-
logger.info({ paused: paused.
|
|
25
|
+
logger.info({ paused: paused.items.length, failed: failed.items.length }, '[Demo] Runs that need attention')
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
listRunsOfAnAutomation()
|
|
@@ -14,7 +14,7 @@ async function listAutomations () {
|
|
|
14
14
|
currentUser,
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
logger.info(result.
|
|
17
|
+
logger.info(result.items.map(automation => ({
|
|
18
18
|
name: automation.name,
|
|
19
19
|
scheduleEnabled: automation.triggers?.schedule?.enabled,
|
|
20
20
|
eventEnabled: automation.triggers?.event?.enabled,
|
|
@@ -5,7 +5,7 @@ async function receive (automationId: string, authorization: string, body: unkno
|
|
|
5
5
|
const logger = new Logger()
|
|
6
6
|
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
8
|
+
const data = await receiveAutomationEvent({
|
|
9
9
|
automationId,
|
|
10
10
|
token: authorization.replace(/^Bearer /, ''),
|
|
11
11
|
payload: body,
|
|
@@ -8,7 +8,7 @@ async function revokeLeakedToken () {
|
|
|
8
8
|
|
|
9
9
|
const result = await revokeAutomationEventToken({ id: '6ad0c9a6d3ea4199c9b7ba10', token: 'eyJ...', currentUser })
|
|
10
10
|
|
|
11
|
-
logger.info({ jti: result.
|
|
11
|
+
logger.info({ jti: result.jti }, '[Demo] That token no longer works, the others still do')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async function rotateAll () {
|
|
@@ -17,7 +17,7 @@ async function rotateAll () {
|
|
|
17
17
|
|
|
18
18
|
const result = await rotateAutomationEventTokens({ id: '6ad0c9a6d3ea4199c9b7ba10', currentUser })
|
|
19
19
|
|
|
20
|
-
logger.info({ eventTokenVersion: result.
|
|
20
|
+
logger.info({ eventTokenVersion: result.eventTokenVersion }, '[Demo] Every token issued before stopped working, issue a new one')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
revokeLeakedToken()
|