openloops 0.1.9 → 0.1.11
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/dist/chunk-XRJFNASX.mjs +14 -0
- package/dist/common/clients/index.d.ts +3 -0
- package/dist/common/clients/index.js +26 -0
- package/dist/common/clients/index.mjs +3 -0
- package/dist/common/clients/llm-client.d.ts +30 -0
- package/dist/common/clients/llm-client.js +159 -0
- package/dist/common/clients/llm-client.mjs +126 -0
- package/dist/common/clients/sentry-client.d.ts +10 -0
- package/dist/common/clients/sentry-client.js +87 -0
- package/dist/common/clients/sentry-client.mjs +53 -0
- package/dist/common/clients/serper-client.d.ts +66 -0
- package/dist/common/clients/serper-client.js +74 -0
- package/dist/common/clients/serper-client.mjs +41 -0
- package/dist/common/core/base.app.d.ts +12 -0
- package/dist/common/core/base.app.js +57 -0
- package/dist/common/core/base.app.mjs +34 -0
- package/dist/common/core/base.entity.d.ts +55 -0
- package/dist/common/core/base.entity.js +208 -0
- package/dist/common/core/base.entity.mjs +179 -0
- package/dist/common/core/base.use-case.d.ts +15 -0
- package/dist/common/core/base.use-case.js +30 -0
- package/dist/common/core/base.use-case.mjs +7 -0
- package/dist/common/core/index.d.ts +1 -0
- package/dist/common/core/index.js +1 -0
- package/dist/common/core/index.mjs +0 -0
- package/dist/common/core/utils/delete-empty-fields.d.ts +1 -0
- package/dist/common/core/utils/delete-empty-fields.js +66 -0
- package/dist/common/core/utils/delete-empty-fields.mjs +43 -0
- package/dist/common/core/utils/flatten-object.d.ts +1 -0
- package/dist/common/core/utils/flatten-object.js +45 -0
- package/dist/common/core/utils/flatten-object.mjs +22 -0
- package/dist/common/core/utils/index.d.ts +3 -0
- package/dist/common/core/utils/index.js +26 -0
- package/dist/common/core/utils/index.mjs +3 -0
- package/dist/common/core/utils/is-plain-object.d.ts +1 -0
- package/dist/common/core/utils/is-plain-object.js +32 -0
- package/dist/common/core/utils/is-plain-object.mjs +9 -0
- package/dist/common/decorators/admin-only/admin-only.d.ts +2 -0
- package/dist/common/decorators/admin-only/admin-only.js +52 -0
- package/dist/common/decorators/admin-only/admin-only.mjs +28 -0
- package/dist/common/decorators/admin-only/index.d.ts +1 -0
- package/dist/common/decorators/admin-only/index.js +22 -0
- package/dist/common/decorators/admin-only/index.mjs +1 -0
- package/dist/common/decorators/index.d.ts +3 -0
- package/dist/common/decorators/index.js +26 -0
- package/dist/common/decorators/index.mjs +3 -0
- package/dist/common/decorators/mask-in-logs/index.d.ts +1 -0
- package/dist/common/decorators/mask-in-logs/index.js +22 -0
- package/dist/common/decorators/mask-in-logs/index.mjs +1 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +2 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.js +53 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +29 -0
- package/dist/common/decorators/owner-only/index.d.ts +1 -0
- package/dist/common/decorators/owner-only/index.js +22 -0
- package/dist/common/decorators/owner-only/index.mjs +1 -0
- package/dist/common/decorators/owner-only/owner-only.d.ts +2 -0
- package/dist/common/decorators/owner-only/owner-only.js +52 -0
- package/dist/common/decorators/owner-only/owner-only.mjs +28 -0
- package/dist/common/error/http-error.d.ts +11 -0
- package/dist/common/error/http-error.js +37 -0
- package/dist/common/error/http-error.mjs +14 -0
- package/dist/common/error/index.d.ts +2 -0
- package/dist/common/error/index.js +24 -0
- package/dist/common/error/index.mjs +2 -0
- package/dist/common/error/reportError.d.ts +2 -0
- package/dist/common/error/reportError.js +51 -0
- package/dist/common/error/reportError.mjs +28 -0
- package/dist/common/helpers/extract-json-from-text.d.ts +1 -0
- package/dist/common/helpers/extract-json-from-text.js +63 -0
- package/dist/common/helpers/extract-json-from-text.mjs +40 -0
- package/dist/common/helpers/index.d.ts +2 -0
- package/dist/common/helpers/index.js +24 -0
- package/dist/common/helpers/index.mjs +2 -0
- package/dist/common/helpers/sanitize-string.d.ts +1 -0
- package/dist/common/helpers/sanitize-string.js +45 -0
- package/dist/common/helpers/sanitize-string.mjs +12 -0
- package/dist/common/logger/index.d.ts +1 -0
- package/dist/common/logger/index.js +22 -0
- package/dist/common/logger/index.mjs +1 -0
- package/dist/common/logger/pino.d.ts +12 -0
- package/dist/common/logger/pino.js +70 -0
- package/dist/common/logger/pino.mjs +36 -0
- package/dist/common/repositories/index.d.ts +2 -0
- package/dist/common/repositories/index.js +24 -0
- package/dist/common/repositories/index.mjs +2 -0
- package/dist/common/repositories/mongo-db.client.d.ts +11 -0
- package/dist/common/repositories/mongo-db.client.js +79 -0
- package/dist/common/repositories/mongo-db.client.mjs +57 -0
- package/dist/common/repositories/mongo-db.repository.d.ts +87 -0
- package/dist/common/repositories/mongo-db.repository.js +219 -0
- package/dist/common/repositories/mongo-db.repository.mjs +196 -0
- package/dist/common/utils/secret-manager.d.ts +15 -0
- package/dist/common/utils/secret-manager.js +105 -0
- package/dist/common/utils/secret-manager.mjs +71 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.js +22 -7
- package/dist/index.mjs +1 -1
- package/dist/services/agent/core/agent-loop.d.ts +38 -0
- package/dist/services/agent/core/agent-loop.js +29 -0
- package/dist/services/agent/core/agent-loop.mjs +6 -0
- package/dist/services/agent/core/agent-state.d.ts +42 -0
- package/dist/services/agent/core/agent-state.js +102 -0
- package/dist/services/agent/core/agent-state.mjs +78 -0
- package/dist/services/agent/core/agent.d.ts +70 -0
- package/dist/services/agent/core/agent.js +351 -0
- package/dist/services/agent/core/agent.mjs +327 -0
- package/dist/services/agent/core/index.d.ts +3 -122
- package/dist/services/agent/core/index.js +26 -7
- package/dist/services/agent/core/index.mjs +3 -1
- package/dist/services/agent/loops/index.d.ts +2 -116
- package/dist/services/agent/loops/index.js +24 -10
- package/dist/services/agent/loops/index.mjs +2 -4
- package/dist/services/agent/loops/plan-execute/index.d.ts +1 -0
- package/dist/services/agent/loops/plan-execute/index.js +22 -0
- package/dist/services/agent/loops/plan-execute/index.mjs +1 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.d.ts +27 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.js +242 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.mjs +226 -0
- package/dist/services/agent/loops/shared/index.d.ts +1 -0
- package/dist/services/agent/loops/shared/index.js +22 -0
- package/dist/services/agent/loops/shared/index.mjs +1 -0
- package/dist/services/agent/loops/shared/skills/action-planner.d.ts +35 -0
- package/dist/services/agent/loops/shared/skills/action-planner.js +68 -0
- package/dist/services/agent/loops/shared/skills/action-planner.mjs +45 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.d.ts +9 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.js +53 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.mjs +30 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.d.ts +9 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.js +70 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.mjs +47 -0
- package/dist/services/agent/loops/shared/skills/final-responder.d.ts +7 -0
- package/dist/services/agent/loops/shared/skills/final-responder.js +57 -0
- package/dist/services/agent/loops/shared/skills/final-responder.mjs +34 -0
- package/dist/services/agent/loops/shared/skills/index.d.ts +6 -0
- package/dist/services/agent/loops/shared/skills/index.js +32 -0
- package/dist/services/agent/loops/shared/skills/index.mjs +6 -0
- package/dist/services/agent/loops/shared/skills/state-observer.d.ts +10 -0
- package/dist/services/agent/loops/shared/skills/state-observer.js +57 -0
- package/dist/services/agent/loops/shared/skills/state-observer.mjs +34 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.d.ts +15 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.js +60 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.mjs +37 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.d.ts +58 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.js +151 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.mjs +128 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.d.ts +59 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.js +231 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.mjs +207 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.d.ts +39 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.js +70 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.mjs +47 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.d.ts +16 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.js +58 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.mjs +35 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.d.ts +17 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.js +63 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.mjs +40 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.d.ts +50 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.js +163 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.mjs +140 -0
- package/dist/services/agent/modules/chats/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/entities/index.js +22 -0
- package/dist/services/agent/modules/chats/entities/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.js +56 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.mjs +27 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.d.ts +15 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.js +61 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.mjs +32 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.js +64 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.mjs +35 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.d.ts +16 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.js +52 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.mjs +23 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.d.ts +16 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.js +59 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.mjs +30 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.d.ts +15 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.js +64 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.mjs +35 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.d.ts +10 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.js +67 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.mjs +38 -0
- package/dist/services/agent/modules/chats/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/repositories/index.js +22 -0
- package/dist/services/agent/modules/chats/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/entities/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/entities/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.d.ts +23 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.js +71 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.mjs +48 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.d.ts +14 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.js +56 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.mjs +27 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.d.ts +15 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.js +61 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.mjs +32 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.d.ts +21 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.js +123 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.mjs +94 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.d.ts +16 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.js +52 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.mjs +23 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.d.ts +15 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.js +62 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.mjs +33 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.d.ts +10 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.js +67 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.mjs +38 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.d.ts +23 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.js +79 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.mjs +56 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.d.ts +14 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.js +56 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.mjs +27 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.d.ts +15 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.js +61 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.mjs +32 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.d.ts +16 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.js +59 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.mjs +30 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.d.ts +15 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.js +61 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.mjs +32 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.d.ts +10 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.js +67 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.mjs +38 -0
- package/dist/services/agent/skills/index.d.ts +2 -14
- package/dist/services/agent/skills/index.js +24 -7
- package/dist/services/agent/skills/index.mjs +2 -1
- package/dist/services/agent/skills/shared/index.d.ts +1 -0
- package/dist/services/agent/skills/shared/index.js +22 -0
- package/dist/services/agent/skills/shared/index.mjs +1 -0
- package/dist/services/agent/skills/shared/shared-rules.d.ts +4 -0
- package/dist/services/agent/skills/shared/shared-rules.js +37 -0
- package/dist/services/agent/skills/shared/shared-rules.mjs +11 -0
- package/dist/services/agent/skills/skill-runner.d.ts +31 -0
- package/dist/services/agent/skills/skill-runner.js +121 -0
- package/dist/services/agent/skills/skill-runner.mjs +92 -0
- package/dist/services/agent/skills/skill.d.ts +33 -0
- package/dist/services/agent/skills/skill.js +128 -0
- package/dist/services/agent/skills/skill.mjs +105 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.d.ts +6 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.js +54 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.mjs +31 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.d.ts +2 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.js +68 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.mjs +45 -0
- package/dist/services/agent/tools/core/call-ai/index.d.ts +1 -0
- package/dist/services/agent/tools/core/call-ai/index.js +22 -0
- package/dist/services/agent/tools/core/call-ai/index.mjs +1 -0
- package/dist/services/agent/tools/core/index.d.ts +2 -0
- package/dist/services/agent/tools/core/index.js +24 -0
- package/dist/services/agent/tools/core/index.mjs +2 -0
- package/dist/services/agent/tools/core/web-search/index.d.ts +1 -0
- package/dist/services/agent/tools/core/web-search/index.js +22 -0
- package/dist/services/agent/tools/core/web-search/index.mjs +1 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.d.ts +2 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.js +51 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.mjs +30 -0
- package/dist/services/agent/tools/index.d.ts +2 -12
- package/dist/services/agent/tools/index.js +24 -7
- package/dist/services/agent/tools/index.mjs +2 -1
- package/dist/{tool-DMR_ZdjP.d.ts → services/agent/tools/tool.d.ts} +7 -9
- package/dist/services/agent/tools/tool.js +57 -0
- package/dist/services/agent/tools/tool.mjs +34 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.d.ts +12 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.js +65 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.mjs +42 -0
- package/dist/services/app/core/app.d.ts +14 -0
- package/dist/services/app/core/app.js +60 -0
- package/dist/services/app/core/app.mjs +47 -0
- package/dist/{current-session-DC-SF7rl.d.mts → services/app/core/current-session.d.ts} +4 -5
- package/dist/services/app/core/current-session.js +124 -0
- package/dist/services/app/core/current-session.mjs +104 -0
- package/dist/services/app/core/current-user.d.ts +16 -0
- package/dist/services/app/core/current-user.js +84 -0
- package/dist/services/app/core/current-user.mjs +61 -0
- package/dist/services/app/core/index.d.ts +3 -60
- package/dist/services/app/core/index.js +26 -7
- package/dist/services/app/core/index.mjs +3 -1
- package/dist/services/app/modules/authentication/lambdas/login/index.d.ts +1 -0
- package/dist/services/app/modules/authentication/lambdas/login/index.js +22 -0
- package/dist/services/app/modules/authentication/lambdas/login/index.mjs +1 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.d.ts +21 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.js +89 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.mjs +50 -0
- package/dist/services/app/modules/users/entities/index.d.ts +1 -0
- package/dist/services/app/modules/users/entities/index.js +22 -0
- package/dist/services/app/modules/users/entities/index.mjs +1 -0
- package/dist/services/app/modules/users/entities/user-acquisition.d.ts +12 -0
- package/dist/services/app/modules/users/entities/user-acquisition.js +55 -0
- package/dist/services/app/modules/users/entities/user-acquisition.mjs +26 -0
- package/dist/services/app/modules/users/entities/user-country.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-country.js +44 -0
- package/dist/services/app/modules/users/entities/user-country.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-currency.d.ts +13 -0
- package/dist/services/app/modules/users/entities/user-currency.js +44 -0
- package/dist/services/app/modules/users/entities/user-currency.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.d.ts +6 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.js +43 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.mjs +20 -0
- package/dist/services/app/modules/users/entities/user-language.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-language.js +44 -0
- package/dist/services/app/modules/users/entities/user-language.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-marketing.d.ts +9 -0
- package/dist/services/app/modules/users/entities/user-marketing.js +53 -0
- package/dist/services/app/modules/users/entities/user-marketing.mjs +24 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.js +41 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.mjs +18 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.d.ts +8 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.js +69 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.mjs +36 -0
- package/dist/services/app/modules/users/entities/user-permissions.d.ts +21 -0
- package/dist/services/app/modules/users/entities/user-permissions.js +59 -0
- package/dist/services/app/modules/users/entities/user-permissions.mjs +36 -0
- package/dist/services/app/modules/users/entities/user-preferences.d.ts +25 -0
- package/dist/services/app/modules/users/entities/user-preferences.js +69 -0
- package/dist/services/app/modules/users/entities/user-preferences.mjs +46 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.d.ts +16 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.js +56 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.mjs +33 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.js +41 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.mjs +18 -0
- package/dist/services/app/modules/users/entities/user-timezone.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-timezone.js +44 -0
- package/dist/services/app/modules/users/entities/user-timezone.mjs +21 -0
- package/dist/services/app/modules/users/entities/user.entity.d.ts +41 -0
- package/dist/services/app/modules/users/entities/user.entity.js +133 -0
- package/dist/services/app/modules/users/entities/user.entity.mjs +103 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.d.ts +14 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.js +58 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.mjs +29 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.d.ts +16 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.js +61 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.mjs +32 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.d.ts +14 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.js +52 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.mjs +23 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.d.ts +16 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.js +52 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.mjs +23 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.d.ts +15 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.js +62 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.mjs +33 -0
- package/dist/services/app/modules/users/repositories/index.d.ts +1 -0
- package/dist/services/app/modules/users/repositories/index.js +22 -0
- package/dist/services/app/modules/users/repositories/index.mjs +1 -0
- package/dist/services/app/modules/users/repositories/user.repository.d.ts +12 -0
- package/dist/services/app/modules/users/repositories/user.repository.js +83 -0
- package/dist/services/app/modules/users/repositories/user.repository.mjs +54 -0
- package/package.json +2 -2
- package/dist/agent-loop-C41Y1CGp.d.mts +0 -60
- package/dist/agent-loop-ZH4GRi4A.d.ts +0 -60
- package/dist/base.use-case-8K6_Ods0.d.mts +0 -14
- package/dist/base.use-case-ChEb3nh6.d.ts +0 -14
- package/dist/chunk-6PCVBY5G.mjs +0 -1
- package/dist/chunk-7WJ3XXSP.mjs +0 -7
- package/dist/chunk-CCRMOWMO.mjs +0 -1
- package/dist/chunk-ISOEJA2L.mjs +0 -1
- package/dist/chunk-XXB52O7H.mjs +0 -1
- package/dist/current-session-DC-SF7rl.d.ts +0 -130
- package/dist/current-user-4BppBUBP.d.mts +0 -264
- package/dist/current-user-4BppBUBP.d.ts +0 -264
- package/dist/index.d.mts +0 -10
- package/dist/services/agent/core/index.d.mts +0 -122
- package/dist/services/agent/loops/index.d.mts +0 -116
- package/dist/services/agent/skills/index.d.mts +0 -14
- package/dist/services/agent/tools/index.d.mts +0 -12
- package/dist/services/app/core/index.d.mts +0 -60
- package/dist/skill-CtYQbG6-.d.ts +0 -308
- package/dist/skill-DXNkK5FG.d.mts +0 -308
- package/dist/tool-BaG2a8Np.d.mts +0 -42
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../../../../common/core/base.use-case.js';
|
|
2
|
+
import { UserRepository } from '../../repositories';
|
|
3
|
+
import { UserProps } from '../../entities';
|
|
4
|
+
export interface Params extends BaseUseCaseParams {
|
|
5
|
+
id: string;
|
|
6
|
+
payload?: UserProps;
|
|
7
|
+
}
|
|
8
|
+
export interface Output extends BaseUseCaseOutput {
|
|
9
|
+
data: UserProps;
|
|
10
|
+
}
|
|
11
|
+
export declare class UpdateUserUseCase extends BaseUseCase<Params, Output> {
|
|
12
|
+
private readonly userRepository;
|
|
13
|
+
constructor(userRepository: UserRepository);
|
|
14
|
+
execute(params: Params): Promise<Output>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result) __defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var update_user_use_case_exports = {};
|
|
28
|
+
__export(update_user_use_case_exports, {
|
|
29
|
+
UpdateUserUseCase: () => UpdateUserUseCase
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(update_user_use_case_exports);
|
|
32
|
+
var import_tsyringe = require("tsyringe");
|
|
33
|
+
var import_base = require("../../../../../../common/core/base.use-case.js");
|
|
34
|
+
var import_entities = require("../../entities");
|
|
35
|
+
let UpdateUserUseCase = class extends import_base.BaseUseCase {
|
|
36
|
+
constructor(userRepository) {
|
|
37
|
+
super();
|
|
38
|
+
this.userRepository = userRepository;
|
|
39
|
+
}
|
|
40
|
+
userRepository;
|
|
41
|
+
async execute(params) {
|
|
42
|
+
const { payload, id, currentUser } = params;
|
|
43
|
+
if (!payload || Object.keys(payload).length === 0) {
|
|
44
|
+
throw new Error("Payload is required for updating user");
|
|
45
|
+
}
|
|
46
|
+
const user = await import_entities.User.create({ ...payload, _id: id });
|
|
47
|
+
user.setUpdatedBy(currentUser);
|
|
48
|
+
this.logger.info(`Updating user: ${user.stringify()}`);
|
|
49
|
+
const result = await this.userRepository.update(user);
|
|
50
|
+
if (!result) {
|
|
51
|
+
throw new Error("User not found or update failed");
|
|
52
|
+
}
|
|
53
|
+
return { data: result };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
UpdateUserUseCase = __decorateClass([
|
|
57
|
+
(0, import_tsyringe.autoInjectable)()
|
|
58
|
+
], UpdateUserUseCase);
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
UpdateUserUseCase
|
|
62
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass
|
|
3
|
+
} from "../../../../../../chunk-XRJFNASX.mjs";
|
|
4
|
+
import { autoInjectable } from "tsyringe";
|
|
5
|
+
import { BaseUseCase } from "../../../../../../common/core/base.use-case.js";
|
|
6
|
+
import { User } from "../../entities";
|
|
7
|
+
let UpdateUserUseCase = class extends BaseUseCase {
|
|
8
|
+
constructor(userRepository) {
|
|
9
|
+
super();
|
|
10
|
+
this.userRepository = userRepository;
|
|
11
|
+
}
|
|
12
|
+
userRepository;
|
|
13
|
+
async execute(params) {
|
|
14
|
+
const { payload, id, currentUser } = params;
|
|
15
|
+
if (!payload || Object.keys(payload).length === 0) {
|
|
16
|
+
throw new Error("Payload is required for updating user");
|
|
17
|
+
}
|
|
18
|
+
const user = await User.create({ ...payload, _id: id });
|
|
19
|
+
user.setUpdatedBy(currentUser);
|
|
20
|
+
this.logger.info(`Updating user: ${user.stringify()}`);
|
|
21
|
+
const result = await this.userRepository.update(user);
|
|
22
|
+
if (!result) {
|
|
23
|
+
throw new Error("User not found or update failed");
|
|
24
|
+
}
|
|
25
|
+
return { data: result };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
UpdateUserUseCase = __decorateClass([
|
|
29
|
+
autoInjectable()
|
|
30
|
+
], UpdateUserUseCase);
|
|
31
|
+
export {
|
|
32
|
+
UpdateUserUseCase
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './user.repository';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var repositories_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(repositories_exports);
|
|
18
|
+
__reExport(repositories_exports, require("./user.repository"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./user.repository")
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./user.repository";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MongoRepository, QueryOptions } from '../../../../../common/repositories/index.js';
|
|
2
|
+
import { User, UserProps } from '../entities';
|
|
3
|
+
export declare class UserRepository {
|
|
4
|
+
readonly _: MongoRepository<UserProps>;
|
|
5
|
+
create(user: User): Promise<User>;
|
|
6
|
+
update(user: User): Promise<UserProps | null>;
|
|
7
|
+
findById(id: string): Promise<UserProps | null>;
|
|
8
|
+
findByExternalId(id: string): Promise<UserProps | null>;
|
|
9
|
+
deleteById(id: string): Promise<number>;
|
|
10
|
+
findByProps(where: Partial<UserProps>, options: QueryOptions): Promise<UserProps[]>;
|
|
11
|
+
findByEmailOrUsernameWithPassword(emailOrUsername: string): Promise<User | null>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result) __defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var user_repository_exports = {};
|
|
28
|
+
__export(user_repository_exports, {
|
|
29
|
+
UserRepository: () => UserRepository
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(user_repository_exports);
|
|
32
|
+
var import_tsyringe = require("tsyringe");
|
|
33
|
+
var import_repositories = require("../../../../../common/repositories/index.js");
|
|
34
|
+
var import_secret_manager = require("../../../../../common/utils/secret-manager.js");
|
|
35
|
+
var import_entities = require("../entities");
|
|
36
|
+
let UserRepository = class {
|
|
37
|
+
_ = new import_repositories.MongoRepository({
|
|
38
|
+
database: import_secret_manager.secretManager.get("OPENLOOPS_DB_NAME"),
|
|
39
|
+
collection: "users"
|
|
40
|
+
});
|
|
41
|
+
async create(user) {
|
|
42
|
+
const id = await this._.createOne({ payload: user.toDocument() });
|
|
43
|
+
id && user.setId(id);
|
|
44
|
+
return user;
|
|
45
|
+
}
|
|
46
|
+
async update(user) {
|
|
47
|
+
const { password, ...rest } = await this._.updateOne({
|
|
48
|
+
payload: user.toFlatDocument(),
|
|
49
|
+
where: { _id: user._id }
|
|
50
|
+
});
|
|
51
|
+
return rest;
|
|
52
|
+
}
|
|
53
|
+
async findById(id) {
|
|
54
|
+
return await this._.findOne({
|
|
55
|
+
where: { _id: this._.parseId(id) },
|
|
56
|
+
select: { password: 0 }
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async findByExternalId(id) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
async deleteById(id) {
|
|
63
|
+
return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
|
|
64
|
+
}
|
|
65
|
+
async findByProps(where, options) {
|
|
66
|
+
return await this._.findMany({ where, select: { password: 0 }, options });
|
|
67
|
+
}
|
|
68
|
+
async findByEmailOrUsernameWithPassword(emailOrUsername) {
|
|
69
|
+
const input = this._.cleanInput(emailOrUsername);
|
|
70
|
+
const user = await this._.findOne({
|
|
71
|
+
where: { $or: [{ email: input }, { username: input }] }
|
|
72
|
+
});
|
|
73
|
+
if (!user) return null;
|
|
74
|
+
return await import_entities.User.create(user);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
UserRepository = __decorateClass([
|
|
78
|
+
(0, import_tsyringe.autoInjectable)()
|
|
79
|
+
], UserRepository);
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
UserRepository
|
|
83
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass
|
|
3
|
+
} from "../../../../../chunk-XRJFNASX.mjs";
|
|
4
|
+
import { autoInjectable } from "tsyringe";
|
|
5
|
+
import { MongoRepository } from "../../../../../common/repositories/index.js";
|
|
6
|
+
import { secretManager } from "../../../../../common/utils/secret-manager.js";
|
|
7
|
+
import { User } from "../entities";
|
|
8
|
+
let UserRepository = class {
|
|
9
|
+
_ = new MongoRepository({
|
|
10
|
+
database: secretManager.get("OPENLOOPS_DB_NAME"),
|
|
11
|
+
collection: "users"
|
|
12
|
+
});
|
|
13
|
+
async create(user) {
|
|
14
|
+
const id = await this._.createOne({ payload: user.toDocument() });
|
|
15
|
+
id && user.setId(id);
|
|
16
|
+
return user;
|
|
17
|
+
}
|
|
18
|
+
async update(user) {
|
|
19
|
+
const { password, ...rest } = await this._.updateOne({
|
|
20
|
+
payload: user.toFlatDocument(),
|
|
21
|
+
where: { _id: user._id }
|
|
22
|
+
});
|
|
23
|
+
return rest;
|
|
24
|
+
}
|
|
25
|
+
async findById(id) {
|
|
26
|
+
return await this._.findOne({
|
|
27
|
+
where: { _id: this._.parseId(id) },
|
|
28
|
+
select: { password: 0 }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async findByExternalId(id) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
async deleteById(id) {
|
|
35
|
+
return await this._.deleteOne({ where: { _id: this._.parseId(id) } });
|
|
36
|
+
}
|
|
37
|
+
async findByProps(where, options) {
|
|
38
|
+
return await this._.findMany({ where, select: { password: 0 }, options });
|
|
39
|
+
}
|
|
40
|
+
async findByEmailOrUsernameWithPassword(emailOrUsername) {
|
|
41
|
+
const input = this._.cleanInput(emailOrUsername);
|
|
42
|
+
const user = await this._.findOne({
|
|
43
|
+
where: { $or: [{ email: input }, { username: input }] }
|
|
44
|
+
});
|
|
45
|
+
if (!user) return null;
|
|
46
|
+
return await User.create(user);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
UserRepository = __decorateClass([
|
|
50
|
+
autoInjectable()
|
|
51
|
+
], UserRepository);
|
|
52
|
+
export {
|
|
53
|
+
UserRepository
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Framework to build AI Agents",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "tsup",
|
|
43
|
+
"build": "tsup && tsc-alias",
|
|
44
44
|
"prepublishOnly": "yarn build",
|
|
45
45
|
"check-size": "npm pack --dry-run",
|
|
46
46
|
"release": "npm version patch && npm publish --access public"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { C as CurrentSession } from './current-session-DC-SF7rl.mjs';
|
|
2
|
-
import { C as CurrentUser } from './current-user-4BppBUBP.mjs';
|
|
3
|
-
import { A as AgentTask, C as Chat, b as SkillRunOptions } from './skill-DXNkK5FG.mjs';
|
|
4
|
-
import { T as Tool, B as BaseParams } from './tool-BaG2a8Np.mjs';
|
|
5
|
-
|
|
6
|
-
declare class Logger {
|
|
7
|
-
private IS_LOCAL;
|
|
8
|
-
private logger;
|
|
9
|
-
private log;
|
|
10
|
-
info(obj?: any, msg?: string): void;
|
|
11
|
-
warn(obj?: any, msg?: string): void;
|
|
12
|
-
debug(obj?: any, msg?: string): void;
|
|
13
|
-
error(obj?: any, msg?: string): void;
|
|
14
|
-
fatal(obj?: any, msg?: string): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface WeightedKeyword {
|
|
18
|
-
keyword: string;
|
|
19
|
-
weight: number;
|
|
20
|
-
}
|
|
21
|
-
interface ScoredTool {
|
|
22
|
-
toolName: string;
|
|
23
|
-
score: number;
|
|
24
|
-
matchedKeywords: string[];
|
|
25
|
-
tool: Tool;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface RunContext {
|
|
29
|
-
task?: AgentTask;
|
|
30
|
-
chat: Chat;
|
|
31
|
-
currentUser: CurrentUser;
|
|
32
|
-
currentSession?: CurrentSession;
|
|
33
|
-
currentMessage: string;
|
|
34
|
-
answerId: string;
|
|
35
|
-
tools: Tool[];
|
|
36
|
-
searchTools: (keywords: WeightedKeyword[], opts?: {
|
|
37
|
-
page?: number;
|
|
38
|
-
limit?: number;
|
|
39
|
-
}) => ScoredTool[];
|
|
40
|
-
baseParams: BaseParams;
|
|
41
|
-
skillParams: Pick<SkillRunOptions, 'sessionId' | 'answerId' | 'userMessage' | 'currentUser' | 'currentSession' | 'chat'>;
|
|
42
|
-
reply: (content: string) => void;
|
|
43
|
-
setNextNode: (node?: string | AgentLoopNode) => void;
|
|
44
|
-
logger: Logger;
|
|
45
|
-
}
|
|
46
|
-
type AgentLoopNode = (ctx: RunContext) => Promise<void>;
|
|
47
|
-
interface Author {
|
|
48
|
-
name: string;
|
|
49
|
-
email: string;
|
|
50
|
-
website?: string;
|
|
51
|
-
}
|
|
52
|
-
declare abstract class AgentLoop {
|
|
53
|
-
abstract get initialNode(): string | AgentLoopNode;
|
|
54
|
-
abstract get nodes(): Record<string, AgentLoopNode>;
|
|
55
|
-
abstract get name(): string;
|
|
56
|
-
abstract get version(): string;
|
|
57
|
-
abstract get author(): Author;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { AgentLoop as A, type RunContext as R, type AgentLoopNode as a, type Author as b };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { C as CurrentSession } from './current-session-DC-SF7rl.js';
|
|
2
|
-
import { C as CurrentUser } from './current-user-4BppBUBP.js';
|
|
3
|
-
import { A as AgentTask, C as Chat, b as SkillRunOptions } from './skill-CtYQbG6-.js';
|
|
4
|
-
import { T as Tool, B as BaseParams } from './tool-DMR_ZdjP.js';
|
|
5
|
-
|
|
6
|
-
declare class Logger {
|
|
7
|
-
private IS_LOCAL;
|
|
8
|
-
private logger;
|
|
9
|
-
private log;
|
|
10
|
-
info(obj?: any, msg?: string): void;
|
|
11
|
-
warn(obj?: any, msg?: string): void;
|
|
12
|
-
debug(obj?: any, msg?: string): void;
|
|
13
|
-
error(obj?: any, msg?: string): void;
|
|
14
|
-
fatal(obj?: any, msg?: string): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface WeightedKeyword {
|
|
18
|
-
keyword: string;
|
|
19
|
-
weight: number;
|
|
20
|
-
}
|
|
21
|
-
interface ScoredTool {
|
|
22
|
-
toolName: string;
|
|
23
|
-
score: number;
|
|
24
|
-
matchedKeywords: string[];
|
|
25
|
-
tool: Tool;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface RunContext {
|
|
29
|
-
task?: AgentTask;
|
|
30
|
-
chat: Chat;
|
|
31
|
-
currentUser: CurrentUser;
|
|
32
|
-
currentSession?: CurrentSession;
|
|
33
|
-
currentMessage: string;
|
|
34
|
-
answerId: string;
|
|
35
|
-
tools: Tool[];
|
|
36
|
-
searchTools: (keywords: WeightedKeyword[], opts?: {
|
|
37
|
-
page?: number;
|
|
38
|
-
limit?: number;
|
|
39
|
-
}) => ScoredTool[];
|
|
40
|
-
baseParams: BaseParams;
|
|
41
|
-
skillParams: Pick<SkillRunOptions, 'sessionId' | 'answerId' | 'userMessage' | 'currentUser' | 'currentSession' | 'chat'>;
|
|
42
|
-
reply: (content: string) => void;
|
|
43
|
-
setNextNode: (node?: string | AgentLoopNode) => void;
|
|
44
|
-
logger: Logger;
|
|
45
|
-
}
|
|
46
|
-
type AgentLoopNode = (ctx: RunContext) => Promise<void>;
|
|
47
|
-
interface Author {
|
|
48
|
-
name: string;
|
|
49
|
-
email: string;
|
|
50
|
-
website?: string;
|
|
51
|
-
}
|
|
52
|
-
declare abstract class AgentLoop {
|
|
53
|
-
abstract get initialNode(): string | AgentLoopNode;
|
|
54
|
-
abstract get nodes(): Record<string, AgentLoopNode>;
|
|
55
|
-
abstract get name(): string;
|
|
56
|
-
abstract get version(): string;
|
|
57
|
-
abstract get author(): Author;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { AgentLoop as A, type RunContext as R, type AgentLoopNode as a, type Author as b };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { C as CurrentSession } from './current-session-DC-SF7rl.mjs';
|
|
2
|
-
import { C as CurrentUser } from './current-user-4BppBUBP.mjs';
|
|
3
|
-
|
|
4
|
-
interface BaseUseCaseParams {
|
|
5
|
-
currentUser?: CurrentUser;
|
|
6
|
-
currentSession?: CurrentSession;
|
|
7
|
-
}
|
|
8
|
-
interface BaseUseCaseOutput {
|
|
9
|
-
message?: string;
|
|
10
|
-
data?: any;
|
|
11
|
-
error?: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type { BaseUseCaseParams as B, BaseUseCaseOutput as a };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { C as CurrentSession } from './current-session-DC-SF7rl.js';
|
|
2
|
-
import { C as CurrentUser } from './current-user-4BppBUBP.js';
|
|
3
|
-
|
|
4
|
-
interface BaseUseCaseParams {
|
|
5
|
-
currentUser?: CurrentUser;
|
|
6
|
-
currentSession?: CurrentSession;
|
|
7
|
-
}
|
|
8
|
-
interface BaseUseCaseOutput {
|
|
9
|
-
message?: string;
|
|
10
|
-
data?: any;
|
|
11
|
-
error?: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type { BaseUseCaseParams as B, BaseUseCaseOutput as a };
|
package/dist/chunk-6PCVBY5G.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as H,b as U,c as D}from"./chunk-ISOEJA2L.mjs";import{a as W}from"./chunk-XXB52O7H.mjs";import{a as rt,b as u,c as J,f as j,g as Q,h as d,m}from"./chunk-7WJ3XXSP.mjs";var K=class{};var V=(o=>(o.IDLE="idle",o.FAILED="failed",o.PROCESSING="processing",o.AWAITING_USER_INPUT="awaiting_user_input",o.AWAITING_USER_CONFIRMATION="awaiting_user_confirmation",o))(V||{}),P=class i{constructor(e,t,s,r,o,n){this.status=e;this.language=t;this.lastError=s;this.activeTaskId=r;this.stopRequested=o;this.currentActivity=n}status;language;lastError;activeTaskId;stopRequested;currentActivity;static fromJSON(e={}){return new i(e.status,e.language,e.lastError,e.activeTaskId,e.stopRequested,e.currentActivity)}toJSON(){return{currentActivity:this.currentActivity,language:this.language,status:this.status,activeTaskId:this.activeTaskId,lastError:this.lastError,stopRequested:this.stopRequested}}setLanguage(e){e&&(this.language=e)}setCurrentActivity(e){this.currentActivity=e}setStatus(e){this.status=e}setActiveTaskId(e){this.activeTaskId=e}setLastError(e){this.lastError=e}setStopRequested(e=!0){this.stopRequested=e}interruptExecution(){this.stopRequested=!0}cleanContext(){this.currentActivity="",this.language="en",this.status="idle",this.activeTaskId=void 0,this.lastError=void 0,this.stopRequested=!1}};import"reflect-metadata";import{container as f}from"tsyringe";import{autoInjectable as ct}from"tsyringe";import{ObjectId as F}from"mongodb";var k=class i extends m{constructor(t,s,r){super(t);this.props=t;this.role=s;this.content=r}props;role;content;static factory(t){let s=t._id&&F.isValid(t._id)?new F(t._id):new F;return i.fromJSON({...t,_id:s})}static fromJSON(t){return new i(t,t.role,t.content)}toJSON(){return{...super.toJSON(),role:this.role,content:this.content}}};var B=class i{constructor(e,t,s,r){this.props=e;this.notifyOnCompletion=t;this.modelName=s;this.loopName=r}props;notifyOnCompletion;modelName;loopName;static fromJSON(e){return new i(e,e.notifyOnCompletion,e.modelName,e.loopName)}toJSON(){return{notifyOnCompletion:this.notifyOnCompletion,modelName:this.modelName,loopName:this.loopName}}setLoopName(e){this.loopName=e}setModelName(e){this.modelName=e}setNotifyOnCompletion(e){this.notifyOnCompletion=e}};var E=class i{constructor(e,t){this.props=e;this.items=t}props;items;MEMORY_CONTEXT_MAX_CHARS=1e4;static fromJSON(e){return new i(e,e.items)}get length(){return this.items?JSON.stringify(this.items).length:0}get allMeta(){return this.items?.map(e=>e.meta)}toJSON(){return{items:this.items}}addContext(e){this.items??=[],this.items.push(e)}selectContext(e){return this.items?.filter(t=>(e.taskId===void 0||t.taskId===e.taskId)&&(e.name===void 0||t.meta.name===e.name))}lastContext(e){let t=this.selectContext(e);return t?.[t.length-1]}compress(){}pruneContext(){}};import{ObjectId as q}from"mongodb";import{ObjectId as G}from"mongodb";var R=class i extends m{constructor(t,s,r,o,n,a,c,g,h,p,y,A,b){super(t);this.props=t;this.name=s;this.stepId=r;this.args=o;this.dependsOn=n;this.status=a;this.output=c;this.error=g;this.reasoning=h;this.retries=p;this.author=y;this.startedAt=A;this.completedAt=b}props;name;stepId;args;dependsOn;status;output;error;reasoning;retries;author;startedAt;completedAt;static factory(t){let s=t._id&&G.isValid(t._id)?new G(t._id):new G;return i.fromJSON({...t,_id:s,status:t.status??"pending"})}static fromJSON(t){return new i(t,t.name,t.stepId,t.args,t.dependsOn,t.status,t.output,t.error,t.reasoning,t.retries,t.author,t.startedAt,t.completedAt)}toJSON(){return{...super.toJSON(),name:this.name,stepId:this.stepId,args:this.args,dependsOn:this.dependsOn,status:this.status,output:this.output,error:this.error,reasoning:this.reasoning,retries:this.retries,author:this.author,startedAt:this.startedAt,completedAt:this.completedAt}}get id(){return this._id.toString()}get isReady(){return this.status==="pending"}get isTerminal(){return this.status==="completed"||this.status==="failed"}dependenciesSatisfiedBy(t){return this.dependsOn?.length?this.dependsOn.every(s=>t.has(s)):!0}markRunning(){this.status="running",this.startedAt=new Date}markCompleted(t){this.status="completed",this.output=t,this.completedAt=new Date}markFailed(t){this.status="failed",this.error=t,this.completedAt=new Date}incrementRetries(){return this.retries=(this.retries??0)+1,this.retries}resetForRetry(){this.status="pending",this.error=void 0,this.startedAt=void 0,this.completedAt=void 0}async runTool(t,s,r){if(!t)return this.markFailed({message:`Tool "${this.name}" not found`}),this;this.markRunning();try{let o=await t.run({...s,...r});this.markCompleted(o?.data)}catch(o){this.markFailed({message:o?.message??String(o)})}return this}};var ot=/^\{\{step_([\w-]+)\.output\}\}$/,nt=/\{\{step_([\w-]+)\.output\}\}/g,it=/^\{\{context\.([\w.-]+)\}\}$/,at=/\{\{context\.([\w.-]+)\}\}/g;function z(i){return typeof i=="object"?JSON.stringify(i):String(i)}var _=class i extends m{constructor(t,s,r,o,n,a,c,g,h=[]){super(t);this.props=t;this.status=s;this.goal=r;this.nextNode=o;this.threadId=n;this.previousTaskId=a;this.summary=c;this.loopName=g;this.actions=h}props;status;goal;nextNode;threadId;previousTaskId;summary;loopName;actions;static factory(t){let s=t._id&&q.isValid(t._id)?new q(t._id):new q;return i.fromJSON({...t,_id:s,status:t.status??"in_progress"})}static fromJSON(t){return new i(t,t.status,t.goal,t.nextNode,t.threadId,t.previousTaskId,t.summary,t.loopName,t.actions?.map(s=>R.factory(s))??[])}toJSON(){return{...super.toJSON(),status:this.status,goal:this.goal,nextNode:this.nextNode,threadId:this.threadId,previousTaskId:this.previousTaskId,summary:this.summary,loopName:this.loopName,actions:this.actions.map(t=>t.toJSON())}}get id(){return this._id.toString()}addAction(t){let s=R.factory({name:t.name,stepId:t.stepId,args:t.args,dependsOn:t.dependsOn,reasoning:t.reasoning,author:t.author});return this.actions.push(s),s}getAction(t){return this.actions.find(s=>s.id===t||s.stepId===t)}findLastByName(t){return this.actions.slice().reverse().find(s=>s.name===t)}get readyActions(){let t=new Set(this.actions.filter(s=>s.status==="completed").flatMap(s=>[s.id,s.stepId].filter(Boolean)));return this.actions.filter(s=>s.isReady&&s.dependenciesSatisfiedBy(t))}get failedActions(){return this.actions.filter(t=>t.status==="failed")}get lastExecutedAction(){return this.actions.slice().reverse().find(t=>t.isTerminal)}setNextNode(t){this.nextNode=t}complete(t){this.status="completed",t&&(this.summary=t),this.nextNode=void 0}fail(){this.status="failed",this.nextNode=void 0}cancel(){this.status="cancelled",this.nextNode=void 0}pause(){(this.status==="in_progress"||this.status==="awaiting_user")&&(this.status="paused")}reopen(){this.status="in_progress",this.nextNode=void 0}resolveArgs(t,s){return this.resolveValue(t.args,s)}resolveValue(t,s){if(typeof t=="string"){let r=t.match(ot);if(r){let n=this.findActionByRef(r[1]);return n?.output!==void 0?n.output:t}let o=t.match(it);if(o){let n=this.readContextValue(o[1],s);return n!==void 0?n:t}return t.replace(nt,(n,a)=>{let c=this.findActionByRef(a);return c?.output!==void 0?z(c.output):""}).replace(at,(n,a)=>{let c=this.readContextValue(a,s);return c!==void 0?z(c):""})}if(Array.isArray(t))return t.map(r=>this.resolveValue(r,s));if(t!==null&&typeof t=="object"){let r={};for(let o of Object.keys(t))r[o]=this.resolveValue(t[o],s);return r}return t}findActionByRef(t){return this.actions.find(s=>s.stepId===t||s.id===t)}readContextValue(t,s){return s.selectContext({taskId:this.id,name:t})?.[0]?.content}async runTool(t,s,r,o){let n=this.addAction(t);return this.executeToolAction(n,s,r,o)}async runReadyAction(t,s,r,o){let n=this.getAction(t);if(!n)throw new Error(`[AgentTask] Action "${t}" not found`);return this.executeToolAction(n,s,r,o)}async executeToolAction(t,s,r,o){let n=this.resolveArgs(t,r),a=await t.runTool(s,n,o);return a.status==="completed"&&a.name&&r.addContext({taskId:this.id,meta:{name:a.name,type:"tool_output",shortDescription:`Output of ${a.name}`},content:a.output}),a}};var l=class i extends m{constructor(t,s,r,o,n=E.fromJSON({}),a=[],c){super(t);this.props=t;this.state=s;this.settings=r;this.messages=o;this.context=n;this.tasks=a;this.traces=c}props;state;settings;messages;context;tasks;traces;static withDefaults(t){let s=new P;return s.cleanContext(),i.fromJSON({state:s.toJSON(),settings:{loopName:t}})}static fromJSON(t){return new i(t,t.state&&P.fromJSON(t.state),t.settings&&B.fromJSON(t.settings),t.messages?.map(s=>k.factory(s)),E.fromJSON(t.context??{}),t.tasks?.map(s=>_.fromJSON(s))??[],t.traces)}get lastAnswer(){return this.messages?.slice().reverse().find(t=>t.role==="assistant")?.content}get activeTask(){if(this.state?.activeTaskId)return this.tasks.find(t=>t.id===this.state?.activeTaskId)}toJSON(){return{...super.toJSON(),state:this.state?.toJSON(),settings:this.settings?.toJSON(),messages:this.messages?.map(t=>t.toJSON()),context:this.context.toJSON(),tasks:this.tasks.map(t=>t.toJSON()),traces:this.traces}}pushMessage(t){this.messages??=[],this.messages.push(k.factory(t))}lastHistoryMessages(t=6){return this.messages?.slice(-t,-1)}addTrace(t){this.traces??=[],this.traces.push({...t,taskId:t.taskId??this.activeTask?.id,timestamp:new Date})}setAgentState(t){this.state=P.fromJSON(t)}getTask(t){return this.tasks.find(s=>s.id===t)}lastCompletedTask(){return this.tasks.slice().reverse().find(t=>t.status==="completed"&&t.loopName===this.settings?.loopName)}createTask(t,s){this.activeTask?.status==="in_progress"&&this.activeTask.pause();let r=s?.continuesFrom?this.getTask(s.continuesFrom):void 0,o=_.factory({goal:t,threadId:r?.threadId,previousTaskId:s?.continuesFrom,loopName:this.settings?.loopName});return o.threadId??=o.id,this.tasks.push(o),this.state?.setActiveTaskId(o.id),o}reopenTask(t){let s=this.getTask(t);if(s)return s.reopen(),this.state?.setActiveTaskId(s.id),s}completeTask(t,s){let r=t?this.getTask(t):this.activeTask;r?.complete(s),this.clearActiveTaskIdIfMatches(r)}failTask(t){let s=t?this.getTask(t):this.activeTask;s?.fail(),this.clearActiveTaskIdIfMatches(s)}cancelTask(t){let s=t?this.getTask(t):this.activeTask;s?.cancel(),this.clearActiveTaskIdIfMatches(s)}clearActiveTaskIdIfMatches(t){t?.id===this.state?.activeTaskId&&this.state?.setActiveTaskId(void 0)}switchLoop(t){this.settings?.loopName&&this.settings.loopName!==t&&(this.activeTask?.pause(),this.state?.setActiveTaskId(void 0)),this.settings?.setLoopName(t)}};var v=class extends d{constructor(t){super();this.chatRepository=t}chatRepository;async execute(t){let{payload:s,currentUser:r}=t,o=l.fromJSON({...s});return o.setCreatedBy(r),o.setOwner(r),{data:await this.chatRepository.create(o)}}};v=u([ct()],v);import{autoInjectable as ut}from"tsyringe";var C=class extends d{constructor(t){super();this.chatRepository=t}chatRepository;async execute(t){let{payload:s,id:r,currentUser:o}=t;if(!r)throw new Error("Id is required for updating Chat");if(!s||Object.keys(s).length===0)throw new Error("Payload is required for updating Chat");let n=l.fromJSON({...s,_id:r});n.setUpdatedBy(o);let a=await this.chatRepository.update(n);if(!a)throw new Error("Chat not found or update failed");return{data:a}}};C=u([ut()],C);import{autoInjectable as dt}from"tsyringe";import{ObjectId as pt}from"mongodb";var N=class extends d{constructor(t){super();this.chatRepository=t}chatRepository;async execute(t){let{options:s,currentUser:r}=t,{page:o=1,limit:n=10}=s||{};return{data:await this.chatRepository._.findMany({where:{ownerId:new pt(r?.userId)},options:{page:o,limit:n,sortBy:{updatedAt:-1}}})}}};N=u([dt()],N);import{autoInjectable as lt}from"tsyringe";import{ObjectId as ht}from"mongodb";var S=class extends d{constructor(t){super();this.mcpServerRepository=t}mcpServerRepository;async execute(t){let{options:s,currentUser:r}=t,{page:o=1,limit:n=10}=s||{};return{data:await this.mcpServerRepository._.findMany({where:{ownerId:new ht(r?.userId)},options:{page:o,limit:n,sortBy:{updatedAt:-1}}})}}};S=u([lt()],S);import{Client as mt}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as gt}from"@modelcontextprotocol/sdk/client/streamableHttp.js";var x=class i extends m{constructor(t,s,r,o,n){super(t);this.props=t;this.name=s;this.url=r;this.type=o;this.headers=n}props;name;url;type;headers;mcpClient;static fromJSON(t){return new i(t,t.name||void 0,t.url||void 0,t.type||void 0,t.headers||void 0)}toJSON(){return{...super.toJSON(),name:this.name,url:this.url,type:this.type,headers:this.headers}}async connect(){if(!this.url)throw new Error(`[McpServer] "${this.name}" is missing a url`);if(this.type!=="http")throw new Error(`[McpServer] "${this.name}" has an unsupported type "${this.type}" \u2014 only "http" is allowed`);let t=new gt(new URL(this.url),{requestInit:{headers:this.headers??{}}}),s=new mt({name:`open-loops-${this.name??"mcp"}`,version:"1.0.0"});return await s.connect(t),this.mcpClient=s,s}async disconnect(){await this.mcpClient?.close(),this.mcpClient=void 0}};import{autoInjectable as ft}from"tsyringe";var O=class extends d{constructor(t){super();this.mcpServerRepository=t}mcpServerRepository;async execute(t){let{payload:s,currentUser:r}=t,o=x.fromJSON({...s});o.setCreatedBy(r),o.setOwner(r);let n=await this.mcpServerRepository.create(o);return{data:o.toJSON()}}};O=u([ft()],O);import{autoInjectable as Ct}from"tsyringe";import{ObjectId as X}from"mongodb";var yt=10,L=class{database;collection;dbClient;_where={deletedAt:null,archivedAt:null};report=Q;constructor(e){let{database:t,collection:s,envvar:r}=e||{};if(!t)throw new Error("[Mongo Repository] Database name is required");if(!s)throw new Error("[Mongo Repository] Collection name is required");if(this.dbClient=W(r),!this.dbClient)throw new Error("[Mongo Repository] Database client not found");this.database=t,this.collection=s}parseId(e){return typeof e=="string"&&X.isValid(e)?new X(e):void 0}cleanInput(e){return e?.replace(/[{}[\]()\/\\]/g,"")}clampLimit(e){let t=Number(e);return!Number.isFinite(t)||t<=0?yt:t}async findOne({where:e,select:t,options:s}){try{return await(await this.dbClient.db(this.database)).collection(this.collection).findOne({...e,...this._where},{...t?{projection:t}:{},...s})}catch(r){throw await this.report(r),r}}async findMany({where:e,select:t,options:s}){try{let o=(await this.dbClient.db(this.database)).collection(this.collection),{page:n=1,limit:a=10}=s||{},c=this.clampLimit(a),g=+n>0?(+n-1)*c:0;return await o.find({...e,...this._where},{projection:t}).sort(s?.sortBy||{_id:-1}).skip(g).limit(c).toArray()}catch(r){throw await this.report(r),r}}async findAll({where:e,select:t}){try{return await(await this.dbClient.db(this.database)).collection(this.collection).find({...e,...this._where},{projection:t}).toArray()}catch(s){throw await this.report(s),s}}async createOne({payload:e}){if(!e||Object.keys(e).length===0)throw new Error("[Mongo Repository] Payload is required for createOne operation");try{let s=(await this.dbClient.db(this.database)).collection(this.collection),{insertedId:r}=await s.insertOne({...e,__v:1});return r}catch(t){throw await this.report(t),t}}async createMany({payload:e}){try{let s=(await this.dbClient.db(this.database)).collection(this.collection),{insertedIds:r}=await s.insertMany(e);return r}catch(t){throw await this.report(t),t}}async updateOne({where:e,payload:t,options:s}){if(!e||Object.keys(e).length===0)throw new Error("[Mongo Repository] Where is required for updateOne operation");if(!t||Object.keys(t).length===0)throw new Error("[Mongo Repository] Payload is required for updateOne operation");try{let o=(await this.dbClient.db(this.database)).collection(this.collection),{_id:n,__v:a,createdAt:c,createdBy:g,toUnset:h,...p}=t,y={...p?{$set:p}:{},...h?{$unset:h}:{}};return await o.findOneAndUpdate({...e,...this._where},{$inc:{__v:1},...y},{returnDocument:"after"})}catch(r){throw await this.report(r),r}}async updateMany({where:e,payload:t}){try{return(await(await this.dbClient.db(this.database)).collection(this.collection).updateMany({...e,...this._where},{$set:t})).modifiedCount}catch(s){throw await this.report(s),s}}async deleteOne({where:e}){try{let s=(await this.dbClient.db(this.database)).collection(this.collection),{deletedCount:r}=await s.deleteOne({...e});return r}catch(t){throw await this.report(t),t}}async deleteMany({where:e}){try{let s=(await this.dbClient.db(this.database)).collection(this.collection),{deletedCount:r}=await s.deleteMany({...e});return r}catch(t){throw await this.report(t),t}}async count({where:e,options:t}){try{return await(await this.dbClient.db(this.database)).collection(this.collection).countDocuments({...e,...t?.includeDeleted?{}:this._where})}catch(s){throw await this.report(s),s}}async aggregate(e){try{return await(await this.dbClient.db(this.database)).collection(this.collection).aggregate(e).toArray()}catch(t){throw await this.report(t),t}}async distinct(e,t){try{return await(await this.dbClient.db(this.database)).collection(this.collection).distinct(e,{...t,...this._where})}catch(s){throw await this.report(s),s}}};var w=class{_=new L({database:j.get("OPENLOOPS_DB_NAME"),collection:"chats"});async create(e){let t=await this._.createOne({payload:e.toDocument()});return t&&e.setId(t),e}async update(e){return await this._.updateOne({where:{_id:e._id},payload:e.toFlatDocument()})}async findById(e,t){return await this._.findOne({where:{_id:this._.parseId(e)},select:t})}async deleteById(e){return await this._.deleteOne({where:{_id:this._.parseId(e)}})}async findByProps(e,t){return await this._.findMany({where:e,options:t})}};w=u([Ct()],w);import{autoInjectable as wt}from"tsyringe";var I=class extends d{constructor(t){super();this.llmCallRepository=t}llmCallRepository;async execute(t){let{filters:s,currentUser:r}=t,{sessionId:o,messageId:n,fromDate:a,toDate:c}=s,g=r?.userId;if(!g)return{data:{}};let h=r?.timezoneOffset,p=new Date,y=new Date(p.getFullYear(),p.getMonth(),1),A=new Date(p.getFullYear(),p.getMonth()+1,0,23,59,59,999),b=a||y,T=c||A,M=[{$match:{ownerId:this.llmCallRepository._.parseId(g),...o?{sessionId:this.llmCallRepository._.parseId(o)}:{},...n?{answerId:this.llmCallRepository._.parseId(n)}:{}}},{$addFields:{fromDateUTC:{$cond:{if:{$and:[b,{$ne:[b,null]}]},then:{$dateSubtract:{startDate:new Date(b),unit:"minute",amount:h||0}},else:null}},toDateUTC:{$cond:{if:{$and:[T,{$ne:[T,null]}]},then:{$dateSubtract:{startDate:new Date(T),unit:"minute",amount:h||0}},else:null}}}},{$match:{$expr:{$and:[{$gte:["$createdAt","$fromDateUTC"]},{$lte:["$createdAt","$toDateUTC"]}]}}},{$group:{_id:"$ownerId",totalTokens:{$sum:"$response.usage.totalTokens"}}}];return{data:{...(await this.llmCallRepository._.aggregate(M))[0],tokensLimit:5e6}}}};I=u([wt()],I);function At(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y(i,e,t=.1){let o=[];for(let n of e){let a=0,c=new Set,g=n.name.replace(/_/g," "),h=n.description||"";for(let{keyword:p,weight:y}of i){if(!p||y<=0)continue;let A=p.trim(),b=At(A),T=new RegExp(`\\b${b}\\b`,"gi"),M=(g.match(T)||[]).length,$=(h.match(T)||[]).length;if(M>0||$>0){c.add(A);let tt=Math.sqrt(M)*2.5,et=Math.sqrt($)*1,st=(tt+et)*y;a+=st}}a>=t&&o.push({toolName:n.name,score:Number(a.toFixed(4)),matchedKeywords:Array.from(c),tool:n})}return o.sort((n,a)=>a.score-n.score)}var bt={NODE_NOT_FOUND:"AGENT_NODE_NOT_FOUND"},Tt=50,Z=class i{updateChatUseCase=f.resolve(C);chatRepository=f.resolve(w);logger=new J;_loop;_tools;_mcps=[];_preHooks=[];_postHooks=[];currentChat;currentUser;currentSession;currentMessage="";answerId="";stopLoop=!1;stopRequested=!1;pendingNextNode;static async getChat(e){return f.resolve(w).findById(e)}static async interruptExecution(e,t){let s=f.resolve(C);new J().debug("[AGENT] Interrupt execution triggered"),await s.execute({id:e,payload:{state:{stopRequested:!0}},currentUser:t})}static async createChatSession(e,t){if(!e)throw new Error("[AGENT] CurrentUser is required to create a new chat");let s=f.resolve(v),r=l.withDefaults(t?.name),{data:o}=await s.execute({payload:r.toJSON(),currentUser:e});if(!o)throw new Error("[AGENT] There was an error creating the chat");return l.fromJSON(o)}static async listUserChats(e,t){let s=f.resolve(N),{page:r,limit:o}=e||{},{data:n}=await s.execute({options:{page:r,limit:o},currentUser:t});return n}static async getLLMUsage(e,t){let s=f.resolve(I),{data:r}=await s.execute({filters:e,currentUser:t});return r}static async listUserMcpServers(e,t){let s=f.resolve(S),{page:r,limit:o}=e||{},{data:n}=await s.execute({options:{page:r,limit:o},currentUser:t});return n}static async createMcpServer(e,t){if(!t)throw new Error("[AGENT] CurrentUser is required to create a new mcp server");let s=f.resolve(O),{data:r}=await s.execute({payload:e,currentUser:t});if(!r)throw new Error("[AGENT] There was an error creating the mcp server");return r}constructor(e){if(!e?.loop)throw new Error("[AGENT] An AgentLoop instance is required");this._loop=e.loop,this._tools=e.tools??[],this.currentChat=l.withDefaults(this._loop.name)}get tools(){return this._tools}get mcps(){return this._mcps}get notifyOnCompletion(){return this.currentChat?.settings?.notifyOnCompletion}get lastAssistantAnswer(){return this.currentChat.lastAnswer}async run(e,t,s){try{let{chatId:r,message:o}=e||{};if(this.logger.debug(e,"[AGENT] Agent started"),!o)throw new Error("[AGENT] Message is required");if(!t)throw new Error("[AGENT] CurrentUser is required");return this.stopLoop=!1,this.stopRequested=!1,this.pendingNextNode=void 0,this.currentUser=t,this.currentSession=s,this.currentMessage=o,this.answerId=new(rt("mongodb")).ObjectId().toString(),await this.preRunner(r),await this.runLoop(),await this.postRunner(),{data:this.currentChat}}catch{this.currentChat.state?.setStatus("failed"),this.currentChat.state?.setCurrentActivity("stopped"),await this.saveChat(),await this.disconnectMcpServers()}}stopAgent(){this.stopLoop=!0}addTool(e){this._tools.push(e)}addHook(e,t){e==="pre_execution"&&this._preHooks.push(t),e==="post_execution"&&this._postHooks.push(t)}async preRunner(e){let t;if(e&&(t=await this.chatRepository?.findById(e)),t)this.logger.debug("[AGENT] Existing chat found"),this.currentChat=l.fromJSON(t),this.currentChat.state?.setStopRequested(!1),this.currentChat.switchLoop(this._loop.name);else{if(this.logger.debug("[AGENT] Not existing chat found"),!this.currentUser)throw new Error("[AGENT] CurrentUser params is required");this.currentChat=await i.createChatSession(this.currentUser,this._loop)}this.currentChat.pushMessage({role:"user",content:this.currentMessage}),this.currentChat.state?.setStatus("processing"),this.currentChat.state?.setCurrentActivity("Starting..."),await this.saveChat({resetStop:!0}),await this.loadMcpServers();for(let s of this._preHooks)await s()}async postRunner(){for(let e of this._postHooks)await e();this.currentChat.state?.setCurrentActivity("stopped"),await this.saveChat(),await this.disconnectMcpServers()}async loadMcpServers(){if(!this.currentUser)return;let e=await i.listUserMcpServers({},this.currentUser);for(let t of e??[]){let s=x.fromJSON(t);try{let r=await s.connect(),{tools:o}=await r.listTools(),n=o.map(a=>H.fromMcp(a,r,{namespace:s.name??"mcp"}));this._tools.push(...n),this._mcps.push(s)}catch(r){this.logger.error({error:r,mcpServer:s.name},"[AGENT] Failed to connect MCP server")}}}async disconnectMcpServers(){for(let e of this._mcps)await e.disconnect().catch(t=>{this.logger.error({error:t,mcpServer:e.name},"[AGENT] Failed to disconnect MCP server")});this._mcps=[]}async saveChat(e){this.currentChat?._id&&(this.logger.debug("[AGENT] Updating chat..."),e?.resetStop||(this.logger.debug("[Agent] Removing stopRequested"),delete this.currentChat.state?.stopRequested),await this.updateChatUseCase?.execute({id:this.currentChat?._id.toString(),payload:this.currentChat.toJSON(),currentUser:this.currentUser}))}async checkInterruptionRequest(){let e=this.currentChat?._id?.toString(),t=e&&await this.chatRepository.findById(e,{state:1});t&&t.state?.stopRequested&&(this.stopRequested=!0)}async runLoop(){this.logger.info("[AGENT] Agent Loop started");let e=0;for(;!this.stopLoop&&e<Tt;){if(e++,await this.checkInterruptionRequest(),this.stopRequested){this.stopLoop=!0,this.currentChat.state?.setStatus("idle"),this.resetNextNode(),this.currentChat.state?.setStopRequested(!1);break}let s=this.currentChat.activeTask?.nextNode??this.pendingNextNode??this.resolveNodeName(this._loop.initialNode),r=s?this._loop.nodes[s]:void 0;if(!r){this.logger.error({nodeName:s,loop:this._loop.name},"[AGENT] Node not found in current loop"),this.currentChat.state?.setStatus("failed"),this.currentChat.state?.setLastError({code:bt.NODE_NOT_FOUND,message:`Node "${s}" is not implemented by loop "${this._loop.name}"`,isRetryable:!1,timestamp:new Date}),this.currentChat.addTrace({node:s??"",reasoning:"Node not found"}),this.stopLoop=!0;break}if(await r.call(this._loop,this.buildRunContext()),await this.saveChat(),!this.currentChat.state||this.currentChat.state?.status==="idle"||this.currentChat.state?.status==="failed"||this.currentChat.state?.status==="awaiting_user_input"||this.currentChat.state?.status==="awaiting_user_confirmation"){this.stopLoop=!0;break}}this.logger.info("[AGENT] Agent Loop stopped")}resetNextNode(){let e=this.resolveNodeName(this._loop.initialNode),t=this.currentChat.activeTask;t?t.setNextNode(e):this.pendingNextNode=e}resolveNodeName(e){return typeof e!="function"?e:Object.entries(this._loop.nodes).find(([,t])=>t===e)?.[0]}searchTools(e,t){this.logger.debug({opts:t},"[AGENT] Searching tools");let s=t?.page??1,r=t?.limit??5,o=Y(e,this._tools);o.length<=5&&!o.some(a=>a.toolName===U.name)&&o.push({toolName:U.name,score:.1,matchedKeywords:[],tool:U}),o.length<=5&&!o.some(a=>a.toolName===D.name)&&o.push({toolName:D.name,score:.1,matchedKeywords:[],tool:D});let n=(s-1)*r;return o.slice(n,n+r)}buildRunContext(){let e=this.currentChat._id?.toString()??"";return{task:this.currentChat.activeTask,chat:this.currentChat,currentUser:this.currentUser,currentSession:this.currentSession,currentMessage:this.currentMessage,answerId:this.answerId,tools:this._tools,searchTools:this.searchTools.bind(this),baseParams:{currentUser:this.currentUser,sessionId:e,answerId:this.answerId},skillParams:{sessionId:e,answerId:this.answerId,userMessage:this.currentMessage,currentUser:this.currentUser,currentSession:this.currentSession,chat:this.currentChat},reply:t=>this.currentChat.pushMessage({_id:this.answerId,role:"assistant",content:t}),setNextNode:t=>{let s=this.resolveNodeName(t),r=this.currentChat.activeTask;r?r.setNextNode(s):this.pendingNextNode=s},logger:this.logger}}};export{K as a,V as b,P as c,bt as d,Z as e};
|