n8n 2.20.6 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstract-server.d.ts +1 -0
- package/dist/abstract-server.js +10 -3
- package/dist/abstract-server.js.map +1 -1
- package/dist/agent-library-bundle.js +5989 -0
- package/dist/auth/auth.service.js +3 -3
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/commands/execute-batch.d.ts +2 -2
- package/dist/commands/export/workflow.d.ts +2 -2
- package/dist/commands/import/workflow.d.ts +3 -0
- package/dist/commands/import/workflow.js +15 -1
- package/dist/commands/import/workflow.js.map +1 -1
- package/dist/commands/start.js +2 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +6 -1
- package/dist/constants.js.map +1 -1
- package/dist/controller.registry.js +6 -0
- package/dist/controller.registry.js.map +1 -1
- package/dist/controllers/auth.controller.js +7 -2
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/controllers/me.controller.d.ts +1 -0
- package/dist/controllers/me.controller.js +4 -1
- package/dist/controllers/me.controller.js.map +1 -1
- package/dist/controllers/users.controller.d.ts +2 -2
- package/dist/credentials/credentials.service.d.ts +1 -0
- package/dist/credentials/credentials.service.js +11 -4
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/evaluation.ee/evaluation-api-error.d.ts +7 -0
- package/dist/evaluation.ee/evaluation-api-error.js +16 -0
- package/dist/evaluation.ee/evaluation-api-error.js.map +1 -0
- package/dist/evaluation.ee/evaluation-config-validator.d.ts +30 -0
- package/dist/evaluation.ee/evaluation-config-validator.js +236 -0
- package/dist/evaluation.ee/evaluation-config-validator.js.map +1 -0
- package/dist/evaluation.ee/evaluation-config.controller.d.ts +24 -0
- package/dist/evaluation.ee/evaluation-config.controller.js +94 -0
- package/dist/evaluation.ee/evaluation-config.controller.js.map +1 -0
- package/dist/evaluation.ee/evaluation-config.service.d.ts +18 -0
- package/dist/evaluation.ee/evaluation-config.service.js +74 -0
- package/dist/evaluation.ee/evaluation-config.service.js.map +1 -0
- package/dist/evaluation.ee/llm-judge-provider-registry.d.ts +13 -0
- package/dist/evaluation.ee/llm-judge-provider-registry.js +122 -0
- package/dist/evaluation.ee/llm-judge-provider-registry.js.map +1 -0
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +5 -0
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +32 -10
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
- package/dist/evaluation.ee/test-runner/workflow-compiler.service.d.ts +22 -0
- package/dist/evaluation.ee/test-runner/workflow-compiler.service.js +285 -0
- package/dist/evaluation.ee/test-runner/workflow-compiler.service.js.map +1 -0
- package/dist/evaluation.ee/test-runs.controller.ee.d.ts +3 -0
- package/dist/evaluation.ee/test-runs.controller.ee.js +26 -9
- package/dist/evaluation.ee/test-runs.controller.ee.js.map +1 -1
- package/dist/evaluation.ee/test-runs.types.ee.d.ts +3 -0
- package/dist/eventbus/message-event-bus/message-event-bus.d.ts +2 -0
- package/dist/eventbus/message-event-bus/message-event-bus.js +54 -46
- package/dist/eventbus/message-event-bus/message-event-bus.js.map +1 -1
- package/dist/events/maps/relay.event-map.d.ts +3 -0
- package/dist/instance-settings-loader/instance-settings-loader.service.d.ts +4 -2
- package/dist/instance-settings-loader/instance-settings-loader.service.js +7 -3
- package/dist/instance-settings-loader/instance-settings-loader.service.js.map +1 -1
- package/dist/instance-settings-loader/loaders/community-packages.instance-settings-loader.d.ts +20 -0
- package/dist/instance-settings-loader/loaders/community-packages.instance-settings-loader.js +235 -0
- package/dist/instance-settings-loader/loaders/community-packages.instance-settings-loader.js.map +1 -0
- package/dist/instance-settings-loader/loaders/{sso.instance-settings-loader.d.ts → sso/oidc.instance-settings-loader.d.ts} +4 -10
- package/dist/instance-settings-loader/loaders/sso/oidc.instance-settings-loader.js +98 -0
- package/dist/instance-settings-loader/loaders/sso/oidc.instance-settings-loader.js.map +1 -0
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.d.ts +10 -0
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js +65 -0
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js.map +1 -0
- package/dist/instance-settings-loader/loaders/sso/saml.instance-settings-loader.d.ts +12 -0
- package/dist/instance-settings-loader/loaders/sso/saml.instance-settings-loader.js +75 -0
- package/dist/instance-settings-loader/loaders/sso/saml.instance-settings-loader.js.map +1 -0
- package/dist/instance-settings-loader/loaders/sso/sso.instance-settings-loader.d.ts +15 -0
- package/dist/instance-settings-loader/loaders/sso/sso.instance-settings-loader.js +75 -0
- package/dist/instance-settings-loader/loaders/sso/sso.instance-settings-loader.js.map +1 -0
- package/dist/load-nodes-and-credentials.d.ts +3 -3
- package/dist/load-nodes-and-credentials.js +25 -17
- package/dist/load-nodes-and-credentials.js.map +1 -1
- package/dist/modules/agents/adapters/agents-credential-provider.d.ts +12 -0
- package/dist/modules/agents/adapters/agents-credential-provider.js +63 -0
- package/dist/modules/agents/adapters/agents-credential-provider.js.map +1 -0
- package/dist/modules/agents/agent-execution.service.d.ts +42 -0
- package/dist/modules/agents/agent-execution.service.js +153 -0
- package/dist/modules/agents/agent-execution.service.js.map +1 -0
- package/dist/modules/agents/agent-message-mapper.d.ts +5 -0
- package/dist/modules/agents/agent-message-mapper.js +43 -0
- package/dist/modules/agents/agent-message-mapper.js.map +1 -0
- package/dist/modules/agents/agent-skills.service.d.ts +24 -0
- package/dist/modules/agents/agent-skills.service.js +166 -0
- package/dist/modules/agents/agent-skills.service.js.map +1 -0
- package/dist/modules/agents/agent-sse-stream.d.ts +15 -0
- package/dist/modules/agents/agent-sse-stream.js +194 -0
- package/dist/modules/agents/agent-sse-stream.js.map +1 -0
- package/dist/modules/agents/agents-tools.service.d.ts +18 -0
- package/dist/modules/agents/agents-tools.service.js +193 -0
- package/dist/modules/agents/agents-tools.service.js.map +1 -0
- package/dist/modules/agents/agents.controller.d.ts +260 -0
- package/dist/modules/agents/agents.controller.js +818 -0
- package/dist/modules/agents/agents.controller.js.map +1 -0
- package/dist/modules/agents/agents.module.d.ts +12 -0
- package/dist/modules/agents/agents.module.js +136 -0
- package/dist/modules/agents/agents.module.js.map +1 -0
- package/dist/modules/agents/agents.service.d.ts +151 -0
- package/dist/modules/agents/agents.service.js +1134 -0
- package/dist/modules/agents/agents.service.js.map +1 -0
- package/dist/modules/agents/builder/agents-builder-prompts.d.ts +27 -0
- package/dist/modules/agents/builder/agents-builder-prompts.js +584 -0
- package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -0
- package/dist/modules/agents/builder/agents-builder-settings.controller.d.ts +11 -0
- package/dist/modules/agents/builder/agents-builder-settings.controller.js +61 -0
- package/dist/modules/agents/builder/agents-builder-settings.controller.js.map +1 -0
- package/dist/modules/agents/builder/agents-builder-settings.service.d.ts +31 -0
- package/dist/modules/agents/builder/agents-builder-settings.service.js +199 -0
- package/dist/modules/agents/builder/agents-builder-settings.service.js.map +1 -0
- package/dist/modules/agents/builder/agents-builder-tools.service.d.ts +31 -0
- package/dist/modules/agents/builder/agents-builder-tools.service.js +420 -0
- package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -0
- package/dist/modules/agents/builder/agents-builder.service.d.ts +26 -0
- package/dist/modules/agents/builder/agents-builder.service.js +164 -0
- package/dist/modules/agents/builder/agents-builder.service.js.map +1 -0
- package/dist/modules/agents/builder/builder-model-lookup.service.d.ts +17 -0
- package/dist/modules/agents/builder/builder-model-lookup.service.js +67 -0
- package/dist/modules/agents/builder/builder-model-lookup.service.js.map +1 -0
- package/dist/modules/agents/builder/builder-tool-names.d.ts +14 -0
- package/dist/modules/agents/builder/builder-tool-names.js +17 -0
- package/dist/modules/agents/builder/builder-tool-names.js.map +1 -0
- package/dist/modules/agents/builder/errors.d.ts +6 -0
- package/dist/modules/agents/builder/errors.js +13 -0
- package/dist/modules/agents/builder/errors.js.map +1 -0
- package/dist/modules/agents/builder/interactive/ask-credential.tool.d.ts +5 -0
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js +29 -0
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -0
- package/dist/modules/agents/builder/interactive/ask-llm.tool.d.ts +2 -0
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js +27 -0
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js.map +1 -0
- package/dist/modules/agents/builder/interactive/ask-question.tool.d.ts +2 -0
- package/dist/modules/agents/builder/interactive/ask-question.tool.js +26 -0
- package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -0
- package/dist/modules/agents/builder/interactive/index.d.ts +4 -0
- package/dist/modules/agents/builder/interactive/index.js +12 -0
- package/dist/modules/agents/builder/interactive/index.js.map +1 -0
- package/dist/modules/agents/builder/interactive/llm-provider-defaults.d.ts +17 -0
- package/dist/modules/agents/builder/interactive/llm-provider-defaults.js +60 -0
- package/dist/modules/agents/builder/interactive/llm-provider-defaults.js.map +1 -0
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.d.ts +13 -0
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +136 -0
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -0
- package/dist/modules/agents/entities/agent-checkpoint.entity.d.ts +9 -0
- package/dist/modules/agents/entities/agent-checkpoint.entity.js +43 -0
- package/dist/modules/agents/entities/agent-checkpoint.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.d.ts +16 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.js +74 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-execution.entity.d.ts +26 -0
- package/dist/modules/agents/entities/agent-execution.entity.js +100 -0
- package/dist/modules/agents/entities/agent-execution.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-message.entity.d.ts +10 -0
- package/dist/modules/agents/entities/agent-message.entity.js +47 -0
- package/dist/modules/agents/entities/agent-message.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-observation-cursor.entity.d.ts +8 -0
- package/dist/modules/agents/entities/agent-observation-cursor.entity.js +37 -0
- package/dist/modules/agents/entities/agent-observation-cursor.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-observation-lock.entity.d.ts +8 -0
- package/dist/modules/agents/entities/agent-observation-lock.entity.js +37 -0
- package/dist/modules/agents/entities/agent-observation-lock.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-observation.entity.d.ts +10 -0
- package/dist/modules/agents/entities/agent-observation.entity.js +47 -0
- package/dist/modules/agents/entities/agent-observation.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-published-version.entity.d.ts +22 -0
- package/dist/modules/agents/entities/agent-published-version.entity.js +67 -0
- package/dist/modules/agents/entities/agent-published-version.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-resource.entity.d.ts +5 -0
- package/dist/modules/agents/entities/agent-resource.entity.js +29 -0
- package/dist/modules/agents/entities/agent-resource.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-thread.entity.d.ts +6 -0
- package/dist/modules/agents/entities/agent-thread.entity.js +33 -0
- package/dist/modules/agents/entities/agent-thread.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent.entity.d.ts +24 -0
- package/dist/modules/agents/entities/agent.entity.js +74 -0
- package/dist/modules/agents/entities/agent.entity.js.map +1 -0
- package/dist/modules/agents/execution-recorder.d.ts +82 -0
- package/dist/modules/agents/execution-recorder.js +272 -0
- package/dist/modules/agents/execution-recorder.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +62 -0
- package/dist/modules/agents/integrations/agent-chat-bridge.js +540 -0
- package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-integration.d.ts +39 -0
- package/dist/modules/agents/integrations/agent-chat-integration.js +45 -0
- package/dist/modules/agents/integrations/agent-chat-integration.js.map +1 -0
- package/dist/modules/agents/integrations/agent-schedule.service.d.ts +30 -0
- package/dist/modules/agents/integrations/agent-schedule.service.js +327 -0
- package/dist/modules/agents/integrations/agent-schedule.service.js.map +1 -0
- package/dist/modules/agents/integrations/callback-store.d.ts +11 -0
- package/dist/modules/agents/integrations/callback-store.js +30 -0
- package/dist/modules/agents/integrations/callback-store.js.map +1 -0
- package/dist/modules/agents/integrations/chat-integration.service.d.ts +58 -0
- package/dist/modules/agents/integrations/chat-integration.service.js +397 -0
- package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -0
- package/dist/modules/agents/integrations/component-mapper.d.ts +57 -0
- package/dist/modules/agents/integrations/component-mapper.js +223 -0
- package/dist/modules/agents/integrations/component-mapper.js.map +1 -0
- package/dist/modules/agents/integrations/cron-validation.d.ts +1 -0
- package/dist/modules/agents/integrations/cron-validation.js +8 -0
- package/dist/modules/agents/integrations/cron-validation.js.map +1 -0
- package/dist/modules/agents/integrations/esm-loader.d.ts +5 -0
- package/dist/modules/agents/integrations/esm-loader.js +24 -0
- package/dist/modules/agents/integrations/esm-loader.js.map +1 -0
- package/dist/modules/agents/integrations/integrations-sync.d.ts +4 -0
- package/dist/modules/agents/integrations/integrations-sync.js +78 -0
- package/dist/modules/agents/integrations/integrations-sync.js.map +1 -0
- package/dist/modules/agents/integrations/n8n-checkpoint-storage.d.ts +36 -0
- package/dist/modules/agents/integrations/n8n-checkpoint-storage.js +148 -0
- package/dist/modules/agents/integrations/n8n-checkpoint-storage.js.map +1 -0
- package/dist/modules/agents/integrations/n8n-memory.d.ts +76 -0
- package/dist/modules/agents/integrations/n8n-memory.js +383 -0
- package/dist/modules/agents/integrations/n8n-memory.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/linear-integration.d.ts +14 -0
- package/dist/modules/agents/integrations/platforms/linear-integration.js +83 -0
- package/dist/modules/agents/integrations/platforms/linear-integration.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.d.ts +12 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.js +81 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.d.ts +30 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.js +122 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.js.map +1 -0
- package/dist/modules/agents/integrations/rich-interaction-tool.d.ts +47 -0
- package/dist/modules/agents/integrations/rich-interaction-tool.js +109 -0
- package/dist/modules/agents/integrations/rich-interaction-tool.js.map +1 -0
- package/dist/modules/agents/integrations/types.d.ts +8 -0
- package/dist/modules/agents/integrations/types.js +12 -0
- package/dist/modules/agents/integrations/types.js.map +1 -0
- package/dist/modules/agents/json-config/agent-config-composition.d.ts +9 -0
- package/dist/modules/agents/json-config/agent-config-composition.js +27 -0
- package/dist/modules/agents/json-config/agent-config-composition.js.map +1 -0
- package/dist/modules/agents/json-config/agent-json-config.d.ts +1022 -0
- package/dist/modules/agents/json-config/agent-json-config.js +128 -0
- package/dist/modules/agents/json-config/agent-json-config.js.map +1 -0
- package/dist/modules/agents/json-config/credential-field-mapping.d.ts +4 -0
- package/dist/modules/agents/json-config/credential-field-mapping.js +41 -0
- package/dist/modules/agents/json-config/credential-field-mapping.js.map +1 -0
- package/dist/modules/agents/json-config/from-json-config.d.ts +18 -0
- package/dist/modules/agents/json-config/from-json-config.js +209 -0
- package/dist/modules/agents/json-config/from-json-config.js.map +1 -0
- package/dist/modules/agents/json-config/integration-config.d.ts +61 -0
- package/dist/modules/agents/json-config/integration-config.js +33 -0
- package/dist/modules/agents/json-config/integration-config.js.map +1 -0
- package/dist/modules/agents/json-config/provider-tool-aliases.d.ts +1 -0
- package/dist/modules/agents/json-config/provider-tool-aliases.js +15 -0
- package/dist/modules/agents/json-config/provider-tool-aliases.js.map +1 -0
- package/dist/modules/agents/json-config/schema-text-serializer.d.ts +2 -0
- package/dist/modules/agents/json-config/schema-text-serializer.js +205 -0
- package/dist/modules/agents/json-config/schema-text-serializer.js.map +1 -0
- package/dist/modules/agents/repositories/agent-checkpoint.repository.d.ts +6 -0
- package/dist/modules/agents/repositories/agent-checkpoint.repository.js +35 -0
- package/dist/modules/agents/repositories/agent-checkpoint.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-execution-thread.repository.d.ts +18 -0
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js +120 -0
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-execution.repository.d.ts +10 -0
- package/dist/modules/agents/repositories/agent-execution.repository.js +59 -0
- package/dist/modules/agents/repositories/agent-execution.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-message.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-message.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-message.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-observation-cursor.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-observation-cursor.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-observation-cursor.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-observation-lock.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-observation-lock.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-observation-lock.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-observation.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-observation.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-observation.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-published-version.repository.d.ts +20 -0
- package/dist/modules/agents/repositories/agent-published-version.repository.js +35 -0
- package/dist/modules/agents/repositories/agent-published-version.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-resource.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-resource.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-resource.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-thread.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-thread.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-thread.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent.repository.d.ts +9 -0
- package/dist/modules/agents/repositories/agent.repository.js +50 -0
- package/dist/modules/agents/repositories/agent.repository.js.map +1 -0
- package/dist/modules/agents/runtime/agent-isolate-pool.d.ts +48 -0
- package/dist/modules/agents/runtime/agent-isolate-pool.js +246 -0
- package/dist/modules/agents/runtime/agent-isolate-pool.js.map +1 -0
- package/dist/modules/agents/runtime/agent-secure-runtime.d.ts +21 -0
- package/dist/modules/agents/runtime/agent-secure-runtime.js +281 -0
- package/dist/modules/agents/runtime/agent-secure-runtime.js.map +1 -0
- package/dist/modules/agents/runtime/sandbox-polyfills.d.ts +1 -0
- package/dist/modules/agents/runtime/sandbox-polyfills.js +74 -0
- package/dist/modules/agents/runtime/sandbox-polyfills.js.map +1 -0
- package/dist/modules/agents/tool-registry.d.ts +13 -0
- package/dist/modules/agents/tool-registry.js +42 -0
- package/dist/modules/agents/tool-registry.js.map +1 -0
- package/dist/modules/agents/tools/environment-tool.d.ts +3 -0
- package/dist/modules/agents/tools/environment-tool.js +26 -0
- package/dist/modules/agents/tools/environment-tool.js.map +1 -0
- package/dist/modules/agents/tools/node-tool-factory.d.ts +10 -0
- package/dist/modules/agents/tools/node-tool-factory.js +100 -0
- package/dist/modules/agents/tools/node-tool-factory.js.map +1 -0
- package/dist/modules/agents/tools/workflow-tool-factory.d.ts +43 -0
- package/dist/modules/agents/tools/workflow-tool-factory.js +404 -0
- package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -0
- package/dist/modules/agents/tracing/builder-telemetry.d.ts +12 -0
- package/dist/modules/agents/tracing/builder-telemetry.js +48 -0
- package/dist/modules/agents/tracing/builder-telemetry.js.map +1 -0
- package/dist/modules/agents/types/components.d.ts +71 -0
- package/dist/modules/agents/types/components.js +3 -0
- package/dist/modules/agents/types/components.js.map +1 -0
- package/dist/modules/agents/types/index.d.ts +1 -0
- package/dist/modules/agents/types/index.js +3 -0
- package/dist/modules/agents/types/index.js.map +1 -0
- package/dist/modules/agents/utils/agent-draft.utils.d.ts +2 -0
- package/dist/modules/agents/utils/agent-draft.utils.js +11 -0
- package/dist/modules/agents/utils/agent-draft.utils.js.map +1 -0
- package/dist/modules/agents/utils/agent-resource-id.d.ts +3 -0
- package/dist/modules/agents/utils/agent-resource-id.js +14 -0
- package/dist/modules/agents/utils/agent-resource-id.js.map +1 -0
- package/dist/modules/chat-hub/chat-hub.module.d.ts +2 -2
- package/dist/modules/chat-hub/chat-hub.settings.controller.d.ts +4 -4
- package/dist/modules/chat-hub/chat-hub.types.d.ts +2 -2
- package/dist/modules/chat-hub/dto/chat-models-request.dto.d.ts +1 -1
- package/dist/modules/community-packages/community-packages.config.js +2 -2
- package/dist/modules/community-packages/community-packages.config.js.map +1 -1
- package/dist/modules/community-packages/community-packages.lifecycle.service.d.ts +4 -1
- package/dist/modules/community-packages/community-packages.lifecycle.service.js +14 -2
- package/dist/modules/community-packages/community-packages.lifecycle.service.js.map +1 -1
- package/dist/modules/community-packages/community-packages.module.d.ts +1 -1
- package/dist/modules/community-packages/community-packages.module.js +10 -5
- package/dist/modules/community-packages/community-packages.module.js.map +1 -1
- package/dist/modules/data-table/data-table.service.js +6 -0
- package/dist/modules/data-table/data-table.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/slack-signature-identifier.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.d.ts +2 -0
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js +10 -0
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js +16 -4
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.d.ts +3 -3
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js +11 -3
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js.map +1 -1
- package/dist/modules/encryption-key-manager/encryption-bootstrap.service.js +4 -2
- package/dist/modules/encryption-key-manager/encryption-bootstrap.service.js.map +1 -1
- package/dist/modules/encryption-key-manager/encryption-key-manager.module.js +5 -2
- package/dist/modules/encryption-key-manager/encryption-key-manager.module.js.map +1 -1
- package/dist/modules/encryption-key-manager/encryption-key.controller.d.ts +3 -3
- package/dist/modules/encryption-key-manager/encryption-key.controller.js +8 -2
- package/dist/modules/encryption-key-manager/encryption-key.controller.js.map +1 -1
- package/dist/modules/encryption-key-manager/key-manager.service.d.ts +5 -1
- package/dist/modules/encryption-key-manager/key-manager.service.js +11 -4
- package/dist/modules/encryption-key-manager/key-manager.service.js.map +1 -1
- package/dist/modules/insights/insights-collection.service.js +1 -0
- package/dist/modules/insights/insights-collection.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/mock-handler.js +17 -49
- package/dist/modules/instance-ai/eval/mock-handler.js.map +1 -1
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.d.ts +1 -0
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.js +21 -3
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +3 -2
- package/dist/modules/instance-ai/instance-ai-settings.service.js +10 -9
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-test.controller.d.ts +21 -2
- package/dist/modules/instance-ai/instance-ai-test.controller.js +35 -3
- package/dist/modules/instance-ai/instance-ai-test.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +72 -42
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.controller.d.ts +2 -0
- package/dist/modules/instance-ai/instance-ai.controller.js +25 -1
- package/dist/modules/instance-ai/instance-ai.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +0 -1
- package/dist/modules/instance-ai/instance-ai.module.js +0 -2
- package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +34 -5
- package/dist/modules/instance-ai/instance-ai.service.js +723 -76
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/liveness/index.d.ts +1 -0
- package/dist/modules/instance-ai/liveness/index.js +7 -0
- package/dist/modules/instance-ai/liveness/index.js.map +1 -0
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +72 -0
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +123 -0
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -0
- package/dist/modules/instance-ai/message-parser.js +85 -6
- package/dist/modules/instance-ai/message-parser.js.map +1 -1
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js +4 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js.map +1 -1
- package/dist/modules/instance-ai/storage/typeorm-memory-storage.js +1 -0
- package/dist/modules/instance-ai/storage/typeorm-memory-storage.js.map +1 -1
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js +23 -7
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +3 -3
- package/dist/modules/mcp/mcp.service.js +12 -9
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/tools/get-execution.tool.js +6 -4
- package/dist/modules/mcp/tools/get-execution.tool.js.map +1 -1
- package/dist/modules/mcp/tools/list-credentials.tool.d.ts +40 -0
- package/dist/modules/mcp/tools/list-credentials.tool.js +148 -0
- package/dist/modules/mcp/tools/list-credentials.tool.js.map +1 -0
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +5 -4
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-suggested-workflow-nodes.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/workflow-builder/get-suggested-workflow-nodes.tool.js +3 -3
- package/dist/modules/mcp/tools/workflow-builder/get-suggested-workflow-nodes.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.js +2 -2
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js +3 -2
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js +3 -3
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.js +12 -4
- package/dist/modules/mcp/tools/workflow-builder/sdk-reference-content.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.js +12 -5
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +1 -2
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-validation.utils.d.ts +5 -1
- package/dist/modules/mcp/tools/workflow-validation.utils.js +4 -2
- package/dist/modules/mcp/tools/workflow-validation.utils.js.map +1 -1
- package/dist/modules/mcp-registry/mcp-registry-node-loader.d.ts +27 -0
- package/dist/modules/mcp-registry/mcp-registry-node-loader.js +105 -0
- package/dist/modules/mcp-registry/mcp-registry-node-loader.js.map +1 -0
- package/dist/modules/mcp-registry/mcp-registry-node-loader.test.d.ts +1 -0
- package/dist/modules/mcp-registry/mcp-registry-node-loader.test.js +244 -0
- package/dist/modules/mcp-registry/mcp-registry-node-loader.test.js.map +1 -0
- package/dist/modules/mcp-registry/mcp-registry.module.d.ts +4 -0
- package/dist/modules/mcp-registry/mcp-registry.module.js +60 -0
- package/dist/modules/mcp-registry/mcp-registry.module.js.map +1 -0
- package/dist/modules/mcp-registry/node-description-transform.d.ts +8 -0
- package/dist/modules/mcp-registry/node-description-transform.js +133 -0
- package/dist/modules/mcp-registry/node-description-transform.js.map +1 -0
- package/dist/modules/mcp-registry/node-description-transform.test.d.ts +1 -0
- package/dist/modules/mcp-registry/node-description-transform.test.js +286 -0
- package/dist/modules/mcp-registry/node-description-transform.test.js.map +1 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.d.ts +8 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.js +31 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.js.map +1 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.test.d.ts +1 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.test.js +41 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.test.js.map +1 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.types.d.ts +36 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.types.js +3 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.types.js.map +1 -0
- package/dist/modules/mcp-registry/registry/mock-servers.d.ts +3 -0
- package/dist/modules/mcp-registry/registry/mock-servers.js +80 -0
- package/dist/modules/mcp-registry/registry/mock-servers.js.map +1 -0
- package/dist/modules/otel/execution-level-tracer.d.ts +1 -1
- package/dist/modules/otel/execution-level-tracer.js +24 -9
- package/dist/modules/otel/execution-level-tracer.js.map +1 -1
- package/dist/modules/otel/execution-level-tracer.types.d.ts +9 -7
- package/dist/modules/otel/execution-level-tracer.types.js +14 -0
- package/dist/modules/otel/execution-level-tracer.types.js.map +1 -1
- package/dist/modules/quick-connect/quick-connect.config.d.ts +176 -0
- package/dist/modules/quick-connect/quick-connect.config.js +8 -0
- package/dist/modules/quick-connect/quick-connect.config.js.map +1 -1
- package/dist/modules/quick-connect/quick-connect.module.d.ts +15 -0
- package/dist/modules/redaction/executions/execution-redaction.service.d.ts +1 -3
- package/dist/modules/redaction/executions/execution-redaction.service.js +2 -6
- package/dist/modules/redaction/executions/execution-redaction.service.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +2 -2
- package/dist/modules/source-control.ee/source-control.service.ee.d.ts +1 -1
- package/dist/modules/sso-oidc/oidc.controller.ee.d.ts +3 -1
- package/dist/modules/sso-oidc/oidc.controller.ee.js +8 -1
- package/dist/modules/sso-oidc/oidc.controller.ee.js.map +1 -1
- package/dist/node-catalog/index.d.ts +1 -0
- package/dist/node-catalog/index.js +6 -0
- package/dist/node-catalog/index.js.map +1 -0
- package/dist/{modules/mcp/tools/workflow-builder/workflow-builder-tools.service.d.ts → node-catalog/node-catalog.service.d.ts} +9 -15
- package/dist/{modules/mcp/tools/workflow-builder/workflow-builder-tools.service.js → node-catalog/node-catalog.service.js} +38 -28
- package/dist/node-catalog/node-catalog.service.js.map +1 -0
- package/dist/node-execution/ephemeral-node-executor.d.ts +47 -0
- package/dist/node-execution/ephemeral-node-executor.js +289 -0
- package/dist/node-execution/ephemeral-node-executor.js.map +1 -0
- package/dist/node-execution/index.d.ts +2 -0
- package/dist/node-execution/index.js +8 -0
- package/dist/node-execution/index.js.map +1 -0
- package/dist/public-api/v1/handlers/audit/audit.handler.d.ts +5 -4
- package/dist/public-api/v1/handlers/audit/audit.handler.js +5 -9
- package/dist/public-api/v1/handlers/audit/audit.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.d.ts +20 -17
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.js +12 -39
- package/dist/public-api/v1/handlers/community-packages/community-packages.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/credentials/credentials.handler.d.ts +12 -49
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js +6 -5
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.columns.handler.d.ts +8 -19
- package/dist/public-api/v1/handlers/data-tables/data-tables.columns.handler.js +11 -11
- package/dist/public-api/v1/handlers/data-tables/data-tables.columns.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.d.ts +9 -17
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js +19 -23
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.rows.handler.d.ts +9 -23
- package/dist/public-api/v1/handlers/data-tables/data-tables.rows.handler.js +17 -27
- package/dist/public-api/v1/handlers/data-tables/data-tables.rows.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/discover/discover.handler.d.ts +11 -9
- package/dist/public-api/v1/handlers/discover/discover.handler.js +5 -3
- package/dist/public-api/v1/handlers/discover/discover.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/executions/executions.handler.d.ts +12 -11
- package/dist/public-api/v1/handlers/executions/executions.handler.js +46 -80
- package/dist/public-api/v1/handlers/executions/executions.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/folders/folders.handler.d.ts +12 -17
- package/dist/public-api/v1/handlers/folders/folders.handler.js +17 -20
- package/dist/public-api/v1/handlers/folders/folders.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/insights/insights.handler.d.ts +5 -4
- package/dist/public-api/v1/handlers/insights/insights.handler.js +9 -5
- package/dist/public-api/v1/handlers/insights/insights.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/projects/projects.handler.d.ts +28 -11
- package/dist/public-api/v1/handlers/projects/projects.handler.js +44 -75
- package/dist/public-api/v1/handlers/projects/projects.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/source-control/source-control.handler.d.ts +5 -6
- package/dist/public-api/v1/handlers/source-control/source-control.handler.js +3 -2
- package/dist/public-api/v1/handlers/source-control/source-control.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/tags/tags.handler.d.ts +9 -8
- package/dist/public-api/v1/handlers/tags/tags.handler.js +11 -8
- package/dist/public-api/v1/handlers/tags/tags.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/users/users.handler.ee.d.ts +14 -11
- package/dist/public-api/v1/handlers/users/users.handler.ee.js +7 -8
- package/dist/public-api/v1/handlers/users/users.handler.ee.js.map +1 -1
- package/dist/public-api/v1/handlers/variables/variables.handler.d.ts +13 -7
- package/dist/public-api/v1/handlers/variables/variables.handler.js +5 -3
- package/dist/public-api/v1/handlers/variables/variables.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/workflows/workflows.handler.d.ts +17 -49
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js +27 -46
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
- package/dist/public-api/v1/shared/handler.types.d.ts +7 -1
- package/dist/public-api/v1/shared/middlewares/global.middleware.d.ts +1 -2
- package/dist/public-api/v1/shared/middlewares/global.middleware.js +7 -6
- package/dist/public-api/v1/shared/middlewares/global.middleware.js.map +1 -1
- package/dist/scaling/constants.d.ts +2 -2
- package/dist/scaling/job-processor.js +2 -0
- package/dist/scaling/job-processor.js.map +1 -1
- package/dist/scaling/pubsub/pubsub.event-map.d.ts +9 -0
- package/dist/scaling/pubsub/pubsub.types.d.ts +3 -1
- package/dist/scaling/scaling.types.d.ts +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/dist/services/frontend.service.js +7 -14
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/services/import.service.d.ts +9 -3
- package/dist/services/import.service.js +72 -5
- package/dist/services/import.service.js.map +1 -1
- package/dist/services/proxy-token-manager.js.map +1 -0
- package/dist/services/workflow-statistics.service.js +1 -0
- package/dist/services/workflow-statistics.service.js.map +1 -1
- package/dist/task-runners/task-broker/task-broker.service.d.ts +2 -0
- package/dist/task-runners/task-broker/task-broker.service.js +13 -1
- package/dist/task-runners/task-broker/task-broker.service.js.map +1 -1
- package/dist/utils/ttl-map.d.ts +17 -0
- package/dist/utils/ttl-map.js +80 -0
- package/dist/utils/ttl-map.js.map +1 -0
- package/dist/webhooks/test-webhooks.d.ts +3 -1
- package/dist/webhooks/test-webhooks.js +11 -3
- package/dist/webhooks/test-webhooks.js.map +1 -1
- package/dist/workflow-execute-additional-data.d.ts +2 -1
- package/dist/workflow-execute-additional-data.js +34 -0
- package/dist/workflow-execute-additional-data.js.map +1 -1
- package/dist/workflow-helpers.d.ts +1 -0
- package/dist/workflow-helpers.js +15 -0
- package/dist/workflow-helpers.js.map +1 -1
- package/dist/workflow-runner.js +2 -0
- package/dist/workflow-runner.js.map +1 -1
- package/dist/workflows/workflow-creation.service.js +1 -0
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow.service.js +4 -0
- package/dist/workflows/workflow.service.js.map +1 -1
- package/package.json +40 -25
- package/dist/instance-settings-loader/loaders/sso.instance-settings-loader.js +0 -203
- package/dist/instance-settings-loader/loaders/sso.instance-settings-loader.js.map +0 -1
- package/dist/modules/instance-ai/proxy-token-manager.js.map +0 -1
- package/dist/modules/mcp/tools/workflow-builder/workflow-builder-tools.service.js.map +0 -1
- /package/dist/{modules/instance-ai → services}/proxy-token-manager.d.ts +0 -0
- /package/dist/{modules/instance-ai → services}/proxy-token-manager.js +0 -0
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.AgentsService = void 0;
|
|
46
|
+
exports.chatThreadId = chatThreadId;
|
|
47
|
+
const api_types_1 = require("@n8n/api-types");
|
|
48
|
+
const agents = __importStar(require("@n8n/agents"));
|
|
49
|
+
const ai_utilities_1 = require("@n8n/ai-utilities");
|
|
50
|
+
const backend_common_1 = require("@n8n/backend-common");
|
|
51
|
+
const config_1 = require("@n8n/config");
|
|
52
|
+
const constants_1 = require("@n8n/constants");
|
|
53
|
+
const db_1 = require("@n8n/db");
|
|
54
|
+
const decorators_1 = require("@n8n/decorators");
|
|
55
|
+
const di_1 = require("@n8n/di");
|
|
56
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
57
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
58
|
+
const uuid_1 = require("uuid");
|
|
59
|
+
const active_executions_1 = require("../../active-executions");
|
|
60
|
+
const credentials_service_1 = require("../../credentials/credentials.service");
|
|
61
|
+
const conflict_error_1 = require("../../errors/response-errors/conflict.error");
|
|
62
|
+
const not_found_error_1 = require("../../errors/response-errors/not-found.error");
|
|
63
|
+
const node_definition_resolver_1 = require("../../modules/instance-ai/node-definition-resolver");
|
|
64
|
+
const node_execution_1 = require("../../node-execution");
|
|
65
|
+
const publisher_service_1 = require("../../scaling/pubsub/publisher.service");
|
|
66
|
+
const url_service_1 = require("../../services/url.service");
|
|
67
|
+
const ttl_map_1 = require("../../utils/ttl-map");
|
|
68
|
+
const workflow_runner_1 = require("../../workflow-runner");
|
|
69
|
+
const workflow_finder_service_1 = require("../../workflows/workflow-finder.service");
|
|
70
|
+
const agents_credential_provider_1 = require("./adapters/agents-credential-provider");
|
|
71
|
+
const agent_draft_utils_1 = require("./utils/agent-draft.utils");
|
|
72
|
+
const agent_resource_id_1 = require("./utils/agent-resource-id");
|
|
73
|
+
const agent_execution_service_1 = require("./agent-execution.service");
|
|
74
|
+
const agent_skills_service_1 = require("./agent-skills.service");
|
|
75
|
+
const agents_tools_service_1 = require("./agents-tools.service");
|
|
76
|
+
const builder_tool_names_1 = require("./builder/builder-tool-names");
|
|
77
|
+
const execution_recorder_1 = require("./execution-recorder");
|
|
78
|
+
const agent_chat_integration_1 = require("./integrations/agent-chat-integration");
|
|
79
|
+
const integrations_sync_1 = require("./integrations/integrations-sync");
|
|
80
|
+
const n8n_checkpoint_storage_1 = require("./integrations/n8n-checkpoint-storage");
|
|
81
|
+
const n8n_memory_1 = require("./integrations/n8n-memory");
|
|
82
|
+
const agent_config_composition_1 = require("./json-config/agent-config-composition");
|
|
83
|
+
const agent_json_config_1 = require("./json-config/agent-json-config");
|
|
84
|
+
const from_json_config_1 = require("./json-config/from-json-config");
|
|
85
|
+
const agent_published_version_repository_1 = require("./repositories/agent-published-version.repository");
|
|
86
|
+
const agent_repository_1 = require("./repositories/agent.repository");
|
|
87
|
+
const agent_secure_runtime_1 = require("./runtime/agent-secure-runtime");
|
|
88
|
+
const tool_registry_1 = require("./tool-registry");
|
|
89
|
+
function chatThreadId(agentId, userId) {
|
|
90
|
+
const baseThreadId = `${builder_tool_names_1.AGENT_THREAD_PREFIX.TEST}${agentId}`;
|
|
91
|
+
return userId ? `${baseThreadId}:${userId}` : baseThreadId;
|
|
92
|
+
}
|
|
93
|
+
let AgentsService = class AgentsService {
|
|
94
|
+
computeRuntimeCacheKey(params) {
|
|
95
|
+
if (params.usePublishedVersion) {
|
|
96
|
+
const parts = [params.agentId, 'published'];
|
|
97
|
+
if (params.integrationType)
|
|
98
|
+
parts.push(params.integrationType);
|
|
99
|
+
return parts.join(':');
|
|
100
|
+
}
|
|
101
|
+
const parts = [params.agentId, 'draft'];
|
|
102
|
+
if (params.n8nUserId)
|
|
103
|
+
parts.push(params.n8nUserId);
|
|
104
|
+
return parts.join(':');
|
|
105
|
+
}
|
|
106
|
+
clearRuntimes(agentId, options = {}) {
|
|
107
|
+
for (const key of this.runtimes.keys()) {
|
|
108
|
+
if (key === agentId || key.startsWith(`${agentId}:`)) {
|
|
109
|
+
this.runtimes.delete(key);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (options.skipBroadcast)
|
|
113
|
+
return;
|
|
114
|
+
if (!this.globalConfig.multiMainSetup.enabled)
|
|
115
|
+
return;
|
|
116
|
+
void this.publisher
|
|
117
|
+
.publishCommand({
|
|
118
|
+
command: 'agent-config-changed',
|
|
119
|
+
payload: { agentId },
|
|
120
|
+
})
|
|
121
|
+
.catch((error) => {
|
|
122
|
+
this.logger.warn(`[AgentsService] Failed to publish agent-config-changed for ${agentId}`, {
|
|
123
|
+
error: error instanceof Error ? error.message : String(error),
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
handleAgentConfigChanged(payload) {
|
|
128
|
+
this.clearRuntimes(payload.agentId, { skipBroadcast: true });
|
|
129
|
+
}
|
|
130
|
+
constructor(logger, agentRepository, projectRelationRepository, workflowRunner, activeExecutions, executionRepository, workflowRepository, userRepository, workflowFinderService, urlService, n8nCheckpointStorage, secureRuntime, ephemeralNodeExecutor, agentsToolsService, n8nMemory, agentExecutionService, agentPublishedVersionRepository, agentSkillsService, publisher, agentsConfig, globalConfig) {
|
|
131
|
+
this.logger = logger;
|
|
132
|
+
this.agentRepository = agentRepository;
|
|
133
|
+
this.projectRelationRepository = projectRelationRepository;
|
|
134
|
+
this.workflowRunner = workflowRunner;
|
|
135
|
+
this.activeExecutions = activeExecutions;
|
|
136
|
+
this.executionRepository = executionRepository;
|
|
137
|
+
this.workflowRepository = workflowRepository;
|
|
138
|
+
this.userRepository = userRepository;
|
|
139
|
+
this.workflowFinderService = workflowFinderService;
|
|
140
|
+
this.urlService = urlService;
|
|
141
|
+
this.n8nCheckpointStorage = n8nCheckpointStorage;
|
|
142
|
+
this.secureRuntime = secureRuntime;
|
|
143
|
+
this.ephemeralNodeExecutor = ephemeralNodeExecutor;
|
|
144
|
+
this.agentsToolsService = agentsToolsService;
|
|
145
|
+
this.n8nMemory = n8nMemory;
|
|
146
|
+
this.agentExecutionService = agentExecutionService;
|
|
147
|
+
this.agentPublishedVersionRepository = agentPublishedVersionRepository;
|
|
148
|
+
this.agentSkillsService = agentSkillsService;
|
|
149
|
+
this.publisher = publisher;
|
|
150
|
+
this.agentsConfig = agentsConfig;
|
|
151
|
+
this.globalConfig = globalConfig;
|
|
152
|
+
this.runtimes = new ttl_map_1.TtlMap(30 * constants_1.Time.minutes.toMilliseconds);
|
|
153
|
+
}
|
|
154
|
+
isNodeToolsModuleEnabled() {
|
|
155
|
+
return this.agentsConfig.modules.includes('node-tools-searcher');
|
|
156
|
+
}
|
|
157
|
+
shouldAttachNodeTools(config) {
|
|
158
|
+
return this.isNodeToolsModuleEnabled() && (0, agent_json_config_1.isNodeToolsEnabled)(config);
|
|
159
|
+
}
|
|
160
|
+
listChatIntegrations() {
|
|
161
|
+
return di_1.Container.get(agent_chat_integration_1.ChatIntegrationRegistry)
|
|
162
|
+
.list()
|
|
163
|
+
.map((i) => ({
|
|
164
|
+
type: i.type,
|
|
165
|
+
label: i.displayLabel,
|
|
166
|
+
icon: i.displayIcon,
|
|
167
|
+
credentialTypes: i.credentialTypes,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
async create(projectId, name) {
|
|
171
|
+
const defaultConfig = {
|
|
172
|
+
name,
|
|
173
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
174
|
+
credential: '',
|
|
175
|
+
instructions: '',
|
|
176
|
+
tools: [],
|
|
177
|
+
skills: [],
|
|
178
|
+
};
|
|
179
|
+
const agent = this.agentRepository.create({
|
|
180
|
+
name,
|
|
181
|
+
projectId,
|
|
182
|
+
schema: defaultConfig,
|
|
183
|
+
versionId: (0, uuid_1.v4)(),
|
|
184
|
+
});
|
|
185
|
+
const saved = await this.agentRepository.save(agent);
|
|
186
|
+
this.logger.debug('Created SDK agent', { agentId: saved.id, projectId });
|
|
187
|
+
return saved;
|
|
188
|
+
}
|
|
189
|
+
async findByProjectId(projectId) {
|
|
190
|
+
return await this.agentRepository.findByProjectId(projectId);
|
|
191
|
+
}
|
|
192
|
+
async findById(agentId, projectId) {
|
|
193
|
+
return await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
194
|
+
}
|
|
195
|
+
async updateName(agentId, projectId, name) {
|
|
196
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
197
|
+
if (!agent) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
agent.name = name;
|
|
201
|
+
if (agent.schema) {
|
|
202
|
+
agent.schema = { ...agent.schema, name };
|
|
203
|
+
}
|
|
204
|
+
(0, agent_draft_utils_1.markAgentDraftDirty)(agent);
|
|
205
|
+
const saved = await this.agentRepository.save(agent);
|
|
206
|
+
this.logger.debug('Updated SDK agent name', { agentId, projectId, name });
|
|
207
|
+
return saved;
|
|
208
|
+
}
|
|
209
|
+
async updateDescription(agentId, projectId, description, updatedAt) {
|
|
210
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
211
|
+
if (!agent) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
if (updatedAt && agent.updatedAt.toISOString() !== updatedAt) {
|
|
215
|
+
throw new conflict_error_1.ConflictError('Agent has been modified');
|
|
216
|
+
}
|
|
217
|
+
agent.description = description;
|
|
218
|
+
if (agent.schema) {
|
|
219
|
+
agent.schema = { ...agent.schema, description };
|
|
220
|
+
}
|
|
221
|
+
(0, agent_draft_utils_1.markAgentDraftDirty)(agent);
|
|
222
|
+
const saved = await this.agentRepository.save(agent);
|
|
223
|
+
this.logger.debug('Updated SDK agent description', { agentId, projectId });
|
|
224
|
+
return saved;
|
|
225
|
+
}
|
|
226
|
+
async findByUser(userId) {
|
|
227
|
+
const projectRelations = await this.projectRelationRepository.findAllByUser(userId);
|
|
228
|
+
const projectIds = projectRelations.map((pr) => pr.projectId);
|
|
229
|
+
if (projectIds.length === 0)
|
|
230
|
+
return [];
|
|
231
|
+
return await this.agentRepository.find({
|
|
232
|
+
where: { projectId: (0, typeorm_1.In)(projectIds) },
|
|
233
|
+
order: { updatedAt: 'DESC' },
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
async findPublishedByUser(userId) {
|
|
237
|
+
const projectRelations = await this.projectRelationRepository.findAllByUser(userId);
|
|
238
|
+
const projectIds = projectRelations.map((pr) => pr.projectId);
|
|
239
|
+
if (projectIds.length === 0)
|
|
240
|
+
return [];
|
|
241
|
+
const agents = await this.agentRepository.find({
|
|
242
|
+
where: { projectId: (0, typeorm_1.In)(projectIds) },
|
|
243
|
+
relations: { publishedVersion: true },
|
|
244
|
+
order: { updatedAt: 'DESC' },
|
|
245
|
+
});
|
|
246
|
+
return agents.filter((agent) => agent.publishedVersion);
|
|
247
|
+
}
|
|
248
|
+
async publishAgent(agentId, projectId, userId) {
|
|
249
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
250
|
+
if (!agent) {
|
|
251
|
+
throw new not_found_error_1.NotFoundError(`Agent "${agentId}" not found`);
|
|
252
|
+
}
|
|
253
|
+
await this.agentRepository.manager.transaction(async (trx) => {
|
|
254
|
+
if (!agent.versionId) {
|
|
255
|
+
agent.versionId = (0, uuid_1.v4)();
|
|
256
|
+
await trx.save(agent);
|
|
257
|
+
}
|
|
258
|
+
agent.publishedVersion = await this.agentPublishedVersionRepository.savePublishedVersion({
|
|
259
|
+
agentId: agent.id,
|
|
260
|
+
schema: agent.schema,
|
|
261
|
+
tools: this.snapshotConfiguredTools(agent.schema, agent.tools ?? {}),
|
|
262
|
+
skills: this.agentSkillsService.snapshotConfiguredSkills(agent.schema, agent.skills ?? {}),
|
|
263
|
+
publishedFromVersionId: agent.versionId,
|
|
264
|
+
model: agent.model,
|
|
265
|
+
provider: agent.provider,
|
|
266
|
+
credentialId: agent.credentialId,
|
|
267
|
+
publishedById: userId,
|
|
268
|
+
}, trx);
|
|
269
|
+
});
|
|
270
|
+
this.clearRuntimes(agentId);
|
|
271
|
+
const credentialIntegrations = (agent.integrations ?? []).filter(api_types_1.isAgentCredentialIntegration);
|
|
272
|
+
if (credentialIntegrations.length > 0) {
|
|
273
|
+
const { ChatIntegrationService } = await Promise.resolve().then(() => __importStar(require('./integrations/chat-integration.service')));
|
|
274
|
+
await di_1.Container.get(ChatIntegrationService)
|
|
275
|
+
.syncToConfig(agent, [], credentialIntegrations)
|
|
276
|
+
.catch((error) => this.logger.warn('Failed to connect integrations on publish', {
|
|
277
|
+
agentId,
|
|
278
|
+
error,
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
281
|
+
this.logger.debug('Published SDK agent', { agentId, projectId, userId });
|
|
282
|
+
return agent;
|
|
283
|
+
}
|
|
284
|
+
async unpublishAgent(agentId, projectId) {
|
|
285
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
286
|
+
if (!agent) {
|
|
287
|
+
throw new not_found_error_1.NotFoundError(`Agent "${agentId}" not found`);
|
|
288
|
+
}
|
|
289
|
+
await this.agentRepository.manager.transaction(async (trx) => {
|
|
290
|
+
await this.agentPublishedVersionRepository.deleteByAgentId(agentId, trx);
|
|
291
|
+
agent.publishedVersion = null;
|
|
292
|
+
const hasActiveSchedule = (agent.integrations ?? []).some((integration) => (0, api_types_1.isAgentScheduleIntegration)(integration) && integration.active);
|
|
293
|
+
if (hasActiveSchedule) {
|
|
294
|
+
agent.integrations = (agent.integrations ?? []).map((integration) => (0, api_types_1.isAgentScheduleIntegration)(integration) ? { ...integration, active: false } : integration);
|
|
295
|
+
await trx.save(agent);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
this.clearRuntimes(agentId);
|
|
299
|
+
const { ChatIntegrationService } = await Promise.resolve().then(() => __importStar(require('./integrations/chat-integration.service')));
|
|
300
|
+
await di_1.Container.get(ChatIntegrationService).disconnect(agentId);
|
|
301
|
+
const { AgentScheduleService } = await Promise.resolve().then(() => __importStar(require('./integrations/agent-schedule.service')));
|
|
302
|
+
di_1.Container.get(AgentScheduleService).deregister(agentId);
|
|
303
|
+
this.logger.debug('Unpublished SDK agent', { agentId, projectId });
|
|
304
|
+
return agent;
|
|
305
|
+
}
|
|
306
|
+
async revertToPublishedAgent(agentId, projectId) {
|
|
307
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
308
|
+
if (!agent) {
|
|
309
|
+
throw new not_found_error_1.NotFoundError(`Agent "${agentId}" not found`);
|
|
310
|
+
}
|
|
311
|
+
const publishedVersion = agent.publishedVersion;
|
|
312
|
+
if (!publishedVersion) {
|
|
313
|
+
throw new conflict_error_1.ConflictError(`Agent "${agentId}" is not published`);
|
|
314
|
+
}
|
|
315
|
+
await this.agentRepository.manager.transaction(async (trx) => {
|
|
316
|
+
agent.schema = publishedVersion.schema ? (0, n8n_workflow_1.deepCopy)(publishedVersion.schema) : null;
|
|
317
|
+
agent.tools = (0, n8n_workflow_1.deepCopy)(publishedVersion.tools ?? {});
|
|
318
|
+
agent.skills = (0, n8n_workflow_1.deepCopy)(publishedVersion.skills ?? {});
|
|
319
|
+
agent.model = publishedVersion.model;
|
|
320
|
+
agent.provider = publishedVersion.provider;
|
|
321
|
+
agent.credentialId = publishedVersion.credentialId;
|
|
322
|
+
agent.versionId = publishedVersion.publishedFromVersionId;
|
|
323
|
+
if (agent.schema) {
|
|
324
|
+
agent.name = agent.schema.name;
|
|
325
|
+
agent.description = agent.schema.description ?? null;
|
|
326
|
+
}
|
|
327
|
+
await trx.save(agent);
|
|
328
|
+
});
|
|
329
|
+
this.clearRuntimes(agentId);
|
|
330
|
+
this.logger.debug('Reverted SDK agent to published version', { agentId, projectId });
|
|
331
|
+
return agent;
|
|
332
|
+
}
|
|
333
|
+
async delete(agentId, projectId) {
|
|
334
|
+
const agent = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
335
|
+
if (!agent) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
await this.agentRepository.remove(agent);
|
|
339
|
+
this.clearRuntimes(agentId);
|
|
340
|
+
try {
|
|
341
|
+
const { AgentScheduleService } = await Promise.resolve().then(() => __importStar(require('./integrations/agent-schedule.service')));
|
|
342
|
+
di_1.Container.get(AgentScheduleService).deregister(agentId);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
this.logger.warn('Failed to stop schedule on agent delete', {
|
|
346
|
+
agentId,
|
|
347
|
+
error: error instanceof Error ? error.message : error,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
await this.clearAllTestChatMessages(agentId);
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
this.logger.warn('Failed to clear test chat on agent delete', {
|
|
355
|
+
agentId,
|
|
356
|
+
error: error instanceof Error ? error.message : error,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
this.logger.debug('Deleted SDK agent', { agentId, projectId });
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
async getChatMessages(threadId) {
|
|
363
|
+
return await this.n8nMemory.getMessages(threadId);
|
|
364
|
+
}
|
|
365
|
+
getMemoryFactory() {
|
|
366
|
+
return (params) => {
|
|
367
|
+
if (params.storage === 'n8n') {
|
|
368
|
+
return this.n8nMemory;
|
|
369
|
+
}
|
|
370
|
+
if (params.storage === 'sqlite') {
|
|
371
|
+
return new agents.SqliteMemory(agents.SqliteMemoryConfigSchema.parse(params));
|
|
372
|
+
}
|
|
373
|
+
throw new Error(`Unsupported memory storage: ${params.storage}`);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
createCredentialProvider(projectId) {
|
|
377
|
+
return new agents_credential_provider_1.AgentsCredentialProvider(di_1.Container.get(credentials_service_1.CredentialsService), projectId);
|
|
378
|
+
}
|
|
379
|
+
async getRuntime(params) {
|
|
380
|
+
const { agentId, projectId, integrationType, usePublishedVersion } = params;
|
|
381
|
+
const cacheKey = this.computeRuntimeCacheKey(params);
|
|
382
|
+
const cached = this.runtimes.get(cacheKey);
|
|
383
|
+
if (cached)
|
|
384
|
+
return cached;
|
|
385
|
+
const agentEntity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
386
|
+
if (!agentEntity)
|
|
387
|
+
throw new not_found_error_1.NotFoundError(`Agent ${agentId} not found`);
|
|
388
|
+
let n8nUserId = params.n8nUserId;
|
|
389
|
+
let agentData = agentEntity;
|
|
390
|
+
if (usePublishedVersion) {
|
|
391
|
+
const publishedSchema = agentEntity.publishedVersion?.schema;
|
|
392
|
+
if (!publishedSchema) {
|
|
393
|
+
throw new not_found_error_1.NotFoundError(`Agent ${agentId} is not published`);
|
|
394
|
+
}
|
|
395
|
+
agentData = {
|
|
396
|
+
...agentEntity,
|
|
397
|
+
schema: publishedSchema,
|
|
398
|
+
tools: agentEntity.publishedVersion?.tools ?? agentEntity.tools ?? {},
|
|
399
|
+
skills: agentEntity.publishedVersion?.skills ?? agentEntity.skills ?? {},
|
|
400
|
+
};
|
|
401
|
+
n8nUserId ??= agentEntity.publishedVersion?.publishedById ?? undefined;
|
|
402
|
+
}
|
|
403
|
+
if (!n8nUserId) {
|
|
404
|
+
throw new n8n_workflow_1.UserError('Agent user owner id is required');
|
|
405
|
+
}
|
|
406
|
+
const credentialProvider = this.createCredentialProvider(projectId);
|
|
407
|
+
const { agent: agentInstance, toolRegistry } = await this.reconstructFromConfig(agentData, credentialProvider, n8nUserId, integrationType);
|
|
408
|
+
this.runtimes.set(cacheKey, { agent: agentInstance, agentId, toolRegistry, projectId });
|
|
409
|
+
const runtime = this.runtimes.get(cacheKey);
|
|
410
|
+
if (!runtime)
|
|
411
|
+
throw new Error(`Agent ${agentId} failed to reconstruct`);
|
|
412
|
+
return runtime;
|
|
413
|
+
}
|
|
414
|
+
makeToolResolver(projectId, userId) {
|
|
415
|
+
return async (ref) => {
|
|
416
|
+
if (ref.type === 'workflow') {
|
|
417
|
+
if (!userId) {
|
|
418
|
+
throw new n8n_workflow_1.UserError('userId is required when agent uses workflow tools');
|
|
419
|
+
}
|
|
420
|
+
const { resolveWorkflowTool } = await Promise.resolve().then(() => __importStar(require('./tools/workflow-tool-factory')));
|
|
421
|
+
return await resolveWorkflowTool(ref, {
|
|
422
|
+
workflowRepository: this.workflowRepository,
|
|
423
|
+
workflowRunner: this.workflowRunner,
|
|
424
|
+
activeExecutions: this.activeExecutions,
|
|
425
|
+
executionRepository: this.executionRepository,
|
|
426
|
+
workflowFinderService: this.workflowFinderService,
|
|
427
|
+
userRepository: this.userRepository,
|
|
428
|
+
userId,
|
|
429
|
+
projectId,
|
|
430
|
+
webhookBaseUrl: this.urlService.getWebhookBaseUrl(),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (ref.type === 'node') {
|
|
434
|
+
const { resolveNodeTool } = await Promise.resolve().then(() => __importStar(require('./tools/node-tool-factory')));
|
|
435
|
+
return await resolveNodeTool(ref, {
|
|
436
|
+
executor: this.ephemeralNodeExecutor,
|
|
437
|
+
projectId,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return null;
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
async injectRuntimeDependencies(params) {
|
|
444
|
+
const { agent, agentId, projectId, credentialProvider, nodeToolsEnabled, integrationType } = params;
|
|
445
|
+
try {
|
|
446
|
+
const { createGetEnvironmentTool } = await Promise.resolve().then(() => __importStar(require('./tools/environment-tool')));
|
|
447
|
+
agent.tool(createGetEnvironmentTool());
|
|
448
|
+
}
|
|
449
|
+
catch (toolError) {
|
|
450
|
+
this.logger.warn('Failed to inject get_environment tool', {
|
|
451
|
+
agentId,
|
|
452
|
+
error: toolError instanceof Error ? toolError.message : String(toolError),
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
const integration = integrationType
|
|
456
|
+
? di_1.Container.get(agent_chat_integration_1.ChatIntegrationRegistry).get(integrationType)
|
|
457
|
+
: undefined;
|
|
458
|
+
if (integration?.supportedComponents !== undefined) {
|
|
459
|
+
try {
|
|
460
|
+
const { createRichInteractionTool } = await Promise.resolve().then(() => __importStar(require('./integrations/rich-interaction-tool')));
|
|
461
|
+
agent.tool(createRichInteractionTool(integrationType));
|
|
462
|
+
}
|
|
463
|
+
catch (toolError) {
|
|
464
|
+
this.logger.warn('Failed to inject rich_interaction tool', {
|
|
465
|
+
agentId,
|
|
466
|
+
error: toolError instanceof Error ? toolError.message : String(toolError),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (nodeToolsEnabled) {
|
|
471
|
+
this.attachNodeToolChain(agent, credentialProvider, projectId);
|
|
472
|
+
}
|
|
473
|
+
if (!agent.hasCheckpointStorage()) {
|
|
474
|
+
agent.checkpoint(this.n8nCheckpointStorage);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
attachNodeToolChain(agent, credentialProvider, projectId) {
|
|
478
|
+
agent.tool(this.agentsToolsService.getRuntimeTools(credentialProvider, projectId));
|
|
479
|
+
}
|
|
480
|
+
async *resumeForChat(config) {
|
|
481
|
+
const { agentId, projectId, runId, toolCallId, resumeData, integrationType } = config;
|
|
482
|
+
const checkpointStatus = await this.n8nCheckpointStorage.getStatus(runId);
|
|
483
|
+
if (checkpointStatus.status === 'expired') {
|
|
484
|
+
throw new n8n_workflow_1.UserError(`Checkpoint ${runId} is expired and cannot be resumed`);
|
|
485
|
+
}
|
|
486
|
+
if (checkpointStatus.status === 'not-found') {
|
|
487
|
+
throw new n8n_workflow_1.UserError(`Checkpoint ${runId} not found and cannot be resumed`);
|
|
488
|
+
}
|
|
489
|
+
const memoryScope = checkpointStatus.checkpoint?.persistence;
|
|
490
|
+
if (!memoryScope) {
|
|
491
|
+
throw new n8n_workflow_1.UserError(`Checkpoint ${runId} has no memory data and cannot be resumed`);
|
|
492
|
+
}
|
|
493
|
+
const threadId = memoryScope.threadId;
|
|
494
|
+
const runtime = await this.getRuntime({
|
|
495
|
+
agentId,
|
|
496
|
+
projectId,
|
|
497
|
+
usePublishedVersion: true,
|
|
498
|
+
integrationType,
|
|
499
|
+
});
|
|
500
|
+
const { agent: agentInstance, toolRegistry } = runtime;
|
|
501
|
+
const recorder = new execution_recorder_1.ExecutionRecorder(toolRegistry);
|
|
502
|
+
const resultStream = await agentInstance.resume('stream', resumeData, {
|
|
503
|
+
runId,
|
|
504
|
+
toolCallId,
|
|
505
|
+
});
|
|
506
|
+
const reader = resultStream.stream.getReader();
|
|
507
|
+
try {
|
|
508
|
+
while (true) {
|
|
509
|
+
const { done, value } = await reader.read();
|
|
510
|
+
if (done)
|
|
511
|
+
break;
|
|
512
|
+
recorder.record(value);
|
|
513
|
+
yield value;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
finally {
|
|
517
|
+
reader.releaseLock();
|
|
518
|
+
}
|
|
519
|
+
const messageRecord = recorder.getMessageRecord();
|
|
520
|
+
void this.agentExecutionService
|
|
521
|
+
.recordMessage({
|
|
522
|
+
threadId,
|
|
523
|
+
agentId,
|
|
524
|
+
agentName: agentInstance.name,
|
|
525
|
+
projectId,
|
|
526
|
+
userMessage: '',
|
|
527
|
+
record: messageRecord,
|
|
528
|
+
hitlStatus: 'resumed',
|
|
529
|
+
})
|
|
530
|
+
.catch((error) => {
|
|
531
|
+
this.logger.warn('Failed to record resumed agent execution', {
|
|
532
|
+
agentId,
|
|
533
|
+
threadId,
|
|
534
|
+
error: error instanceof Error ? error.message : String(error),
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
async validateAgentIsRunnable(agentId, projectId, credentialProvider) {
|
|
539
|
+
const agentEntity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
540
|
+
if (!agentEntity) {
|
|
541
|
+
return { missing: ['agent'] };
|
|
542
|
+
}
|
|
543
|
+
const config = agentEntity.schema;
|
|
544
|
+
const missing = [];
|
|
545
|
+
if (!config) {
|
|
546
|
+
return { missing: ['instructions', 'model'] };
|
|
547
|
+
}
|
|
548
|
+
if (!config.instructions?.trim()) {
|
|
549
|
+
missing.push('instructions');
|
|
550
|
+
}
|
|
551
|
+
const modelSchema = agent_json_config_1.AgentJsonConfigSchema.shape.model;
|
|
552
|
+
if (!config.model || !modelSchema.safeParse(config.model).success) {
|
|
553
|
+
missing.push('model');
|
|
554
|
+
}
|
|
555
|
+
if (config.credential) {
|
|
556
|
+
try {
|
|
557
|
+
const credentialName = config.credential;
|
|
558
|
+
const creds = await credentialProvider.list();
|
|
559
|
+
const exists = creds.some((c) => c.id === credentialName || c.name.toLowerCase() === credentialName.toLowerCase());
|
|
560
|
+
if (!exists)
|
|
561
|
+
missing.push('credential');
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
missing.push(...this.agentSkillsService
|
|
567
|
+
.getMissingSkillIds(config, agentEntity.skills ?? {})
|
|
568
|
+
.map((skillId) => `skill:${skillId}`));
|
|
569
|
+
return { missing };
|
|
570
|
+
}
|
|
571
|
+
async *executeForChat(config) {
|
|
572
|
+
const { agentId, projectId, message, userId, memory } = config;
|
|
573
|
+
const runtime = await this.getRuntime({ agentId, projectId, n8nUserId: userId });
|
|
574
|
+
yield* this.streamChatResponse({
|
|
575
|
+
agentInstance: runtime.agent,
|
|
576
|
+
toolRegistry: runtime.toolRegistry,
|
|
577
|
+
agentId,
|
|
578
|
+
message,
|
|
579
|
+
memory,
|
|
580
|
+
projectId: runtime.projectId,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
async getTestChatMessages(agentId, userId) {
|
|
584
|
+
return await this.n8nMemory.getMessages(chatThreadId(agentId, userId), {
|
|
585
|
+
resourceId: userId,
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async clearTestChatMessages(agentId, userId) {
|
|
589
|
+
await this.n8nMemory.deleteMessagesByThread(chatThreadId(agentId, userId), userId);
|
|
590
|
+
}
|
|
591
|
+
async clearAllTestChatMessages(agentId) {
|
|
592
|
+
const threadId = chatThreadId(agentId);
|
|
593
|
+
await this.n8nMemory.deleteThreadsByPrefix(threadId);
|
|
594
|
+
await this.n8nMemory.deleteMessagesByThread(threadId);
|
|
595
|
+
await this.n8nMemory.deleteThread(threadId);
|
|
596
|
+
}
|
|
597
|
+
async *executeForChatPublished(config) {
|
|
598
|
+
const { agentId, projectId, message, memory, integrationType } = config;
|
|
599
|
+
const runtime = await this.getRuntime({
|
|
600
|
+
agentId,
|
|
601
|
+
projectId,
|
|
602
|
+
integrationType,
|
|
603
|
+
usePublishedVersion: true,
|
|
604
|
+
});
|
|
605
|
+
yield* this.streamChatResponse({
|
|
606
|
+
agentInstance: runtime.agent,
|
|
607
|
+
toolRegistry: runtime.toolRegistry,
|
|
608
|
+
agentId,
|
|
609
|
+
message,
|
|
610
|
+
memory,
|
|
611
|
+
projectId: runtime.projectId,
|
|
612
|
+
source: integrationType,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
async *executeForSchedulePublished(config) {
|
|
616
|
+
const { agentId, projectId, message, memory } = config;
|
|
617
|
+
const runtime = await this.getRuntime({
|
|
618
|
+
agentId,
|
|
619
|
+
projectId,
|
|
620
|
+
integrationType: api_types_1.AGENT_SCHEDULE_TRIGGER_TYPE,
|
|
621
|
+
usePublishedVersion: true,
|
|
622
|
+
});
|
|
623
|
+
yield* this.streamChatResponse({
|
|
624
|
+
agentInstance: runtime.agent,
|
|
625
|
+
toolRegistry: runtime.toolRegistry,
|
|
626
|
+
agentId,
|
|
627
|
+
message,
|
|
628
|
+
memory,
|
|
629
|
+
projectId: runtime.projectId,
|
|
630
|
+
source: api_types_1.AGENT_SCHEDULE_TRIGGER_TYPE,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
async *streamChatResponse(config) {
|
|
634
|
+
const { agentInstance, toolRegistry, agentId, message, memory, projectId, source } = config;
|
|
635
|
+
const { threadId, resourceId } = memory;
|
|
636
|
+
const recorder = new execution_recorder_1.ExecutionRecorder(toolRegistry);
|
|
637
|
+
const resultStream = await agentInstance.stream(message, {
|
|
638
|
+
persistence: { threadId, resourceId },
|
|
639
|
+
});
|
|
640
|
+
const reader = resultStream.stream.getReader();
|
|
641
|
+
try {
|
|
642
|
+
while (true) {
|
|
643
|
+
const { done, value } = await reader.read();
|
|
644
|
+
if (done)
|
|
645
|
+
break;
|
|
646
|
+
recorder.record(value);
|
|
647
|
+
if (value.type === 'tool-call-suspended') {
|
|
648
|
+
this.logger.info('Chat: tool-call-suspended chunk received', {
|
|
649
|
+
agentId,
|
|
650
|
+
toolCallId: value.toolCallId,
|
|
651
|
+
toolName: value.toolName,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
yield value;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
finally {
|
|
658
|
+
reader.releaseLock();
|
|
659
|
+
}
|
|
660
|
+
const messageRecord = recorder.getMessageRecord();
|
|
661
|
+
void this.agentExecutionService
|
|
662
|
+
.recordMessage({
|
|
663
|
+
threadId,
|
|
664
|
+
agentId,
|
|
665
|
+
agentName: agentInstance.name,
|
|
666
|
+
projectId,
|
|
667
|
+
userMessage: message,
|
|
668
|
+
record: messageRecord,
|
|
669
|
+
hitlStatus: recorder.suspended ? 'suspended' : undefined,
|
|
670
|
+
source,
|
|
671
|
+
})
|
|
672
|
+
.catch((error) => {
|
|
673
|
+
this.logger.warn('Failed to record agent execution', {
|
|
674
|
+
agentId,
|
|
675
|
+
threadId,
|
|
676
|
+
error: error instanceof Error ? error.message : String(error),
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
async compileIsolated(agentEntity, credentialProvider, userId) {
|
|
681
|
+
if (!agentEntity.schema) {
|
|
682
|
+
return { ok: false, error: 'Agent has no JSON config. Create a config first.' };
|
|
683
|
+
}
|
|
684
|
+
try {
|
|
685
|
+
const { agent: reconstructed } = await this.reconstructFromConfig(agentEntity, credentialProvider, userId);
|
|
686
|
+
return { ok: true, agent: reconstructed };
|
|
687
|
+
}
|
|
688
|
+
catch (e) {
|
|
689
|
+
return {
|
|
690
|
+
ok: false,
|
|
691
|
+
error: e instanceof Error ? e.message : 'Unknown compilation error',
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
async executeForWorkflow(agentId, message, executionId, threadId, userId, projectId) {
|
|
696
|
+
const agentEntity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
697
|
+
if (!agentEntity) {
|
|
698
|
+
throw new n8n_workflow_1.OperationalError('Agent not found or not accessible.');
|
|
699
|
+
}
|
|
700
|
+
if (!agentEntity.publishedVersion) {
|
|
701
|
+
throw new n8n_workflow_1.OperationalError('Agent is not published. Publish the agent before using it in a workflow.');
|
|
702
|
+
}
|
|
703
|
+
const credentialProvider = new agents_credential_provider_1.AgentsCredentialProvider(di_1.Container.get(credentials_service_1.CredentialsService), projectId);
|
|
704
|
+
const compiled = await this.compileIsolated(agentEntity, credentialProvider, userId);
|
|
705
|
+
if (!compiled.ok || !compiled.agent) {
|
|
706
|
+
throw new n8n_workflow_1.OperationalError(`Failed to compile agent: ${compiled.error ?? 'unknown error'}`);
|
|
707
|
+
}
|
|
708
|
+
const agentInstance = compiled.agent;
|
|
709
|
+
const recorder = new execution_recorder_1.ExecutionRecorder();
|
|
710
|
+
let structuredOutput = null;
|
|
711
|
+
const toolCalls = [];
|
|
712
|
+
const toolInputs = new Map();
|
|
713
|
+
const resultStream = await agentInstance.stream(message, {
|
|
714
|
+
persistence: { resourceId: executionId, threadId },
|
|
715
|
+
});
|
|
716
|
+
const reader = resultStream.stream.getReader();
|
|
717
|
+
try {
|
|
718
|
+
while (true) {
|
|
719
|
+
const { done, value } = await reader.read();
|
|
720
|
+
if (done)
|
|
721
|
+
break;
|
|
722
|
+
recorder.record(value);
|
|
723
|
+
if (value.type === 'tool-call') {
|
|
724
|
+
toolInputs.set(value.toolCallId, { toolName: value.toolName, input: value.input });
|
|
725
|
+
}
|
|
726
|
+
else if (value.type === 'tool-result') {
|
|
727
|
+
const pending = toolInputs.get(value.toolCallId);
|
|
728
|
+
toolCalls.push({
|
|
729
|
+
toolName: value.toolName,
|
|
730
|
+
input: pending?.input ?? null,
|
|
731
|
+
result: value.output,
|
|
732
|
+
});
|
|
733
|
+
toolInputs.delete(value.toolCallId);
|
|
734
|
+
}
|
|
735
|
+
else if (value.type === 'finish' && value.structuredOutput !== undefined) {
|
|
736
|
+
structuredOutput = value.structuredOutput;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
finally {
|
|
741
|
+
reader.releaseLock();
|
|
742
|
+
}
|
|
743
|
+
const messageRecord = recorder.getMessageRecord();
|
|
744
|
+
void this.agentExecutionService
|
|
745
|
+
.recordMessage({
|
|
746
|
+
threadId,
|
|
747
|
+
agentId,
|
|
748
|
+
agentName: agentInstance.name,
|
|
749
|
+
projectId,
|
|
750
|
+
userMessage: message,
|
|
751
|
+
record: messageRecord,
|
|
752
|
+
source: api_types_1.AGENT_WORKFLOW_TRIGGER_TYPE,
|
|
753
|
+
})
|
|
754
|
+
.catch((error) => {
|
|
755
|
+
this.logger.warn('Failed to record agent execution from workflow', {
|
|
756
|
+
agentId,
|
|
757
|
+
threadId,
|
|
758
|
+
error: error instanceof Error ? error.message : String(error),
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
if (recorder.suspended) {
|
|
762
|
+
throw new n8n_workflow_1.OperationalError('Agent execution suspended waiting for tool approval. ' +
|
|
763
|
+
'Suspend/resume is not supported in workflow execution context.');
|
|
764
|
+
}
|
|
765
|
+
if (messageRecord.error) {
|
|
766
|
+
throw new n8n_workflow_1.OperationalError(`Agent execution failed: ${messageRecord.error}`);
|
|
767
|
+
}
|
|
768
|
+
if (messageRecord.finishReason === 'error') {
|
|
769
|
+
throw new n8n_workflow_1.OperationalError('Agent execution finished with an error.');
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
response: messageRecord.assistantResponse,
|
|
773
|
+
structuredOutput: structuredOutput ?? null,
|
|
774
|
+
usage: messageRecord.usage
|
|
775
|
+
? {
|
|
776
|
+
promptTokens: messageRecord.usage.promptTokens,
|
|
777
|
+
completionTokens: messageRecord.usage.completionTokens,
|
|
778
|
+
totalTokens: messageRecord.usage.totalTokens,
|
|
779
|
+
}
|
|
780
|
+
: null,
|
|
781
|
+
toolCalls,
|
|
782
|
+
finishReason: messageRecord.finishReason,
|
|
783
|
+
session: {
|
|
784
|
+
agentId,
|
|
785
|
+
projectId,
|
|
786
|
+
sessionId: threadId,
|
|
787
|
+
},
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
async getConfig(agentId, projectId) {
|
|
791
|
+
const entity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
792
|
+
if (!entity)
|
|
793
|
+
throw new not_found_error_1.NotFoundError('Agent not found');
|
|
794
|
+
const config = (0, agent_config_composition_1.composeJsonConfig)(entity);
|
|
795
|
+
if (!config) {
|
|
796
|
+
throw new n8n_workflow_1.UserError('Agent has no JSON config yet.');
|
|
797
|
+
}
|
|
798
|
+
return config;
|
|
799
|
+
}
|
|
800
|
+
async validateConfig(raw) {
|
|
801
|
+
const parsed = agent_json_config_1.AgentJsonConfigSchema.safeParse(raw);
|
|
802
|
+
if (!parsed.success) {
|
|
803
|
+
return { valid: false, error: parsed.error.message };
|
|
804
|
+
}
|
|
805
|
+
const config = parsed.data;
|
|
806
|
+
if ((0, agent_json_config_1.isNodeToolsEnabled)(config.config) && !this.isNodeToolsModuleEnabled()) {
|
|
807
|
+
return {
|
|
808
|
+
valid: false,
|
|
809
|
+
error: 'config.nodeTools.enabled requires the node-tools-searcher agents module to be enabled.',
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
try {
|
|
813
|
+
this.validateNodeToolExpressions(config);
|
|
814
|
+
}
|
|
815
|
+
catch (error) {
|
|
816
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
817
|
+
return {
|
|
818
|
+
valid: false,
|
|
819
|
+
error: `Invalid $fromAI expression in node tool config: ${message}`,
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
const nodeError = await this.validateNodeToolConfigs(config);
|
|
823
|
+
if (nodeError) {
|
|
824
|
+
return { valid: false, error: nodeError };
|
|
825
|
+
}
|
|
826
|
+
return { valid: true, config };
|
|
827
|
+
}
|
|
828
|
+
validateNodeToolExpressions(config) {
|
|
829
|
+
for (const tool of config.tools ?? []) {
|
|
830
|
+
if (tool.type !== 'node')
|
|
831
|
+
continue;
|
|
832
|
+
(0, ai_utilities_1.extractFromAIParameters)((tool.node.nodeParameters ?? {}));
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async healIntegrationCredentialNames(rawConfig) {
|
|
836
|
+
if (!rawConfig || typeof rawConfig !== 'object')
|
|
837
|
+
return rawConfig;
|
|
838
|
+
const cfg = rawConfig;
|
|
839
|
+
if (!Array.isArray(cfg.integrations))
|
|
840
|
+
return rawConfig;
|
|
841
|
+
const missingIds = new Set();
|
|
842
|
+
for (const integration of cfg.integrations) {
|
|
843
|
+
if (!integration || typeof integration !== 'object')
|
|
844
|
+
continue;
|
|
845
|
+
const i = integration;
|
|
846
|
+
if (typeof i.credentialId === 'string' && i.credentialName === undefined) {
|
|
847
|
+
missingIds.add(i.credentialId);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (missingIds.size === 0)
|
|
851
|
+
return rawConfig;
|
|
852
|
+
const credentials = await di_1.Container.get(db_1.CredentialsRepository).findBy({
|
|
853
|
+
id: (0, typeorm_1.In)(Array.from(missingIds)),
|
|
854
|
+
});
|
|
855
|
+
const namesById = new Map(credentials.map((c) => [c.id, c.name]));
|
|
856
|
+
const integrations = cfg.integrations;
|
|
857
|
+
return {
|
|
858
|
+
...cfg,
|
|
859
|
+
integrations: integrations.map((integration) => {
|
|
860
|
+
if (!integration || typeof integration !== 'object')
|
|
861
|
+
return integration;
|
|
862
|
+
const i = integration;
|
|
863
|
+
if (typeof i.credentialId !== 'string' || i.credentialName !== undefined) {
|
|
864
|
+
return integration;
|
|
865
|
+
}
|
|
866
|
+
const name = namesById.get(i.credentialId);
|
|
867
|
+
return name ? { ...integration, credentialName: name } : integration;
|
|
868
|
+
}),
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
async updateConfig(agentId, projectId, config) {
|
|
872
|
+
const entity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
873
|
+
if (!entity)
|
|
874
|
+
throw new not_found_error_1.NotFoundError('Agent not found');
|
|
875
|
+
const healedConfig = await this.healIntegrationCredentialNames(config);
|
|
876
|
+
const result = await this.validateConfig(healedConfig);
|
|
877
|
+
if (!result.valid) {
|
|
878
|
+
throw new n8n_workflow_1.UserError(`Invalid agent config: ${result.error}`);
|
|
879
|
+
}
|
|
880
|
+
this.validateConfigRefs(result.config, entity);
|
|
881
|
+
const previousIntegrations = entity.integrations ?? [];
|
|
882
|
+
const previousSchema = entity.schema ?? null;
|
|
883
|
+
const integrationsProvided = result.config.integrations !== undefined;
|
|
884
|
+
const toolsProvided = result.config.tools !== undefined;
|
|
885
|
+
const skillsProvided = result.config.skills !== undefined;
|
|
886
|
+
const descriptionProvided = result.config.description !== undefined;
|
|
887
|
+
const credentialProvided = result.config.credential !== undefined;
|
|
888
|
+
const memoryProvided = result.config.memory !== undefined;
|
|
889
|
+
const providerToolsProvided = result.config.providerTools !== undefined;
|
|
890
|
+
const configBlockProvided = result.config.config !== undefined;
|
|
891
|
+
const { schemaConfig: decomposedSchema, integrations: decomposedIntegrations } = (0, agent_config_composition_1.decomposeJsonConfig)(result.config);
|
|
892
|
+
const nextIntegrations = integrationsProvided ? decomposedIntegrations : previousIntegrations;
|
|
893
|
+
const nextSchema = {
|
|
894
|
+
...(previousSchema ?? {}),
|
|
895
|
+
name: decomposedSchema.name,
|
|
896
|
+
model: decomposedSchema.model,
|
|
897
|
+
instructions: decomposedSchema.instructions,
|
|
898
|
+
...(descriptionProvided ? { description: decomposedSchema.description } : {}),
|
|
899
|
+
...(credentialProvided ? { credential: decomposedSchema.credential } : {}),
|
|
900
|
+
...(memoryProvided ? { memory: decomposedSchema.memory } : {}),
|
|
901
|
+
...(toolsProvided ? { tools: decomposedSchema.tools } : {}),
|
|
902
|
+
...(skillsProvided ? { skills: decomposedSchema.skills } : {}),
|
|
903
|
+
...(providerToolsProvided ? { providerTools: decomposedSchema.providerTools } : {}),
|
|
904
|
+
...(configBlockProvided ? { config: decomposedSchema.config } : {}),
|
|
905
|
+
};
|
|
906
|
+
entity.schema = nextSchema;
|
|
907
|
+
entity.name = result.config.name;
|
|
908
|
+
if (descriptionProvided)
|
|
909
|
+
entity.description = result.config.description ?? null;
|
|
910
|
+
entity.integrations = nextIntegrations;
|
|
911
|
+
(0, agent_draft_utils_1.markAgentDraftDirty)(entity);
|
|
912
|
+
if (toolsProvided) {
|
|
913
|
+
const referencedIds = new Set((result.config.tools ?? [])
|
|
914
|
+
.filter((t) => t.type === 'custom')
|
|
915
|
+
.map((t) => t.id));
|
|
916
|
+
const orphanIds = Object.keys(entity.tools).filter((id) => !referencedIds.has(id));
|
|
917
|
+
if (orphanIds.length > 0) {
|
|
918
|
+
const tools = { ...entity.tools };
|
|
919
|
+
for (const id of orphanIds) {
|
|
920
|
+
delete tools[id];
|
|
921
|
+
}
|
|
922
|
+
entity.tools = tools;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (skillsProvided) {
|
|
926
|
+
this.agentSkillsService.removeUnreferencedSkills(entity, result.config);
|
|
927
|
+
}
|
|
928
|
+
this.clearRuntimes(agentId);
|
|
929
|
+
const saved = await this.agentRepository.save(entity);
|
|
930
|
+
this.logger.debug('Updated agent JSON config', { agentId, projectId });
|
|
931
|
+
if (integrationsProvided) {
|
|
932
|
+
await (0, integrations_sync_1.syncAgentIntegrations)(saved, previousIntegrations, nextIntegrations, this.logger);
|
|
933
|
+
}
|
|
934
|
+
return {
|
|
935
|
+
config: (0, agent_config_composition_1.composeJsonConfig)(saved) ?? result.config,
|
|
936
|
+
updatedAt: saved.updatedAt.toISOString(),
|
|
937
|
+
versionId: saved.versionId,
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
async buildCustomTool(agentId, projectId, code, descriptor) {
|
|
941
|
+
const entity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
942
|
+
if (!entity)
|
|
943
|
+
throw new not_found_error_1.NotFoundError('Agent not found');
|
|
944
|
+
const toolId = (0, agent_resource_id_1.generateAgentResourceId)('tool', Object.keys(entity.tools ?? {}));
|
|
945
|
+
entity.tools = {
|
|
946
|
+
...entity.tools,
|
|
947
|
+
[toolId]: { code, descriptor },
|
|
948
|
+
};
|
|
949
|
+
(0, agent_draft_utils_1.markAgentDraftDirty)(entity);
|
|
950
|
+
this.clearRuntimes(agentId);
|
|
951
|
+
await this.agentRepository.save(entity);
|
|
952
|
+
this.logger.debug('Built custom tool', { agentId, projectId, toolId });
|
|
953
|
+
return { ok: true, id: toolId, descriptor };
|
|
954
|
+
}
|
|
955
|
+
async listSkills(agentId, projectId) {
|
|
956
|
+
return await this.agentSkillsService.listSkills(agentId, projectId);
|
|
957
|
+
}
|
|
958
|
+
async getSkill(agentId, projectId, skillId) {
|
|
959
|
+
return await this.agentSkillsService.getSkill(agentId, projectId, skillId);
|
|
960
|
+
}
|
|
961
|
+
async createSkill(agentId, projectId, skill) {
|
|
962
|
+
const result = await this.agentSkillsService.createSkill(agentId, projectId, skill);
|
|
963
|
+
this.clearRuntimes(agentId);
|
|
964
|
+
return result;
|
|
965
|
+
}
|
|
966
|
+
async createAndAttachSkill(agentId, projectId, skill) {
|
|
967
|
+
const result = await this.agentSkillsService.createAndAttachSkill(agentId, projectId, skill);
|
|
968
|
+
this.clearRuntimes(agentId);
|
|
969
|
+
return result;
|
|
970
|
+
}
|
|
971
|
+
async updateSkill(agentId, projectId, skillId, updates) {
|
|
972
|
+
const result = await this.agentSkillsService.updateSkill(agentId, projectId, skillId, updates);
|
|
973
|
+
this.clearRuntimes(agentId);
|
|
974
|
+
return result;
|
|
975
|
+
}
|
|
976
|
+
async deleteCustomTool(agentId, projectId, toolId) {
|
|
977
|
+
const entity = await this.agentRepository.findByIdAndProjectId(agentId, projectId);
|
|
978
|
+
if (!entity)
|
|
979
|
+
throw new not_found_error_1.NotFoundError('Agent not found');
|
|
980
|
+
const tools = { ...entity.tools };
|
|
981
|
+
delete tools[toolId];
|
|
982
|
+
entity.tools = tools;
|
|
983
|
+
if (entity.schema?.tools) {
|
|
984
|
+
entity.schema.tools = entity.schema.tools.filter((t) => !(t.type === 'custom' && 'id' in t && t.id === toolId));
|
|
985
|
+
}
|
|
986
|
+
(0, agent_draft_utils_1.markAgentDraftDirty)(entity);
|
|
987
|
+
this.clearRuntimes(agentId);
|
|
988
|
+
await this.agentRepository.save(entity);
|
|
989
|
+
this.logger.debug('Deleted custom tool', { agentId, projectId, toolId });
|
|
990
|
+
}
|
|
991
|
+
async deleteSkill(agentId, projectId, skillId) {
|
|
992
|
+
await this.agentSkillsService.deleteSkill(agentId, projectId, skillId);
|
|
993
|
+
this.clearRuntimes(agentId);
|
|
994
|
+
}
|
|
995
|
+
async validateNodeToolConfigs(config) {
|
|
996
|
+
const nodeTools = (config.tools ?? []).filter((t) => t.type === 'node');
|
|
997
|
+
if (nodeTools.length === 0)
|
|
998
|
+
return null;
|
|
999
|
+
const { setSchemaBaseDirs, validateNodeConfig } = await Promise.resolve().then(() => __importStar(require('@n8n/workflow-sdk')));
|
|
1000
|
+
const dirs = (0, node_definition_resolver_1.resolveBuiltinNodeDefinitionDirs)();
|
|
1001
|
+
if (dirs.length > 0) {
|
|
1002
|
+
setSchemaBaseDirs(dirs);
|
|
1003
|
+
}
|
|
1004
|
+
const errors = [];
|
|
1005
|
+
for (const tool of nodeTools) {
|
|
1006
|
+
const nodeType = tool.node.nodeType;
|
|
1007
|
+
const nodeTypeVersion = tool.node.nodeTypeVersion;
|
|
1008
|
+
const nodeParameters = tool.node.nodeParameters ?? {};
|
|
1009
|
+
const result = validateNodeConfig(nodeType, nodeTypeVersion, { parameters: nodeParameters }, { isToolNode: true });
|
|
1010
|
+
if (!result.valid) {
|
|
1011
|
+
const messages = result.errors
|
|
1012
|
+
.map((e) => e.message)
|
|
1013
|
+
.join('; ');
|
|
1014
|
+
errors.push(`Node tool "${tool.name}" (${nodeType}@${nodeTypeVersion}): ${messages}`);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return errors.length > 0 ? errors.join('\n') : null;
|
|
1018
|
+
}
|
|
1019
|
+
validateConfigRefs(config, entity) {
|
|
1020
|
+
const missingSkillIds = this.agentSkillsService.getMissingSkillIds(config, entity.skills ?? {});
|
|
1021
|
+
if (missingSkillIds.length > 0) {
|
|
1022
|
+
throw new n8n_workflow_1.UserError(`Invalid agent config: Missing skill bodies: ${missingSkillIds.join(', ')}`);
|
|
1023
|
+
}
|
|
1024
|
+
const missingToolIds = this.getMissingCustomToolIds(config, entity.tools ?? {});
|
|
1025
|
+
if (missingToolIds.length > 0) {
|
|
1026
|
+
throw new n8n_workflow_1.UserError(`Invalid agent config: Missing custom tool definitions: ${missingToolIds.join(', ')}`);
|
|
1027
|
+
}
|
|
1028
|
+
const activeUnpublishedSchedule = (config.integrations ?? []).some((integration) => (0, api_types_1.isAgentScheduleIntegration)(integration) && integration.active);
|
|
1029
|
+
if (activeUnpublishedSchedule && !entity.publishedVersion) {
|
|
1030
|
+
throw new n8n_workflow_1.UserError('Invalid agent config: schedule integration cannot be active until the agent is published');
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
getMissingCustomToolIds(config, tools) {
|
|
1034
|
+
const refs = (config?.tools ?? []).filter((ref) => ref.type === 'custom');
|
|
1035
|
+
const seen = new Set();
|
|
1036
|
+
const missing = [];
|
|
1037
|
+
for (const ref of refs) {
|
|
1038
|
+
if (seen.has(ref.id))
|
|
1039
|
+
continue;
|
|
1040
|
+
seen.add(ref.id);
|
|
1041
|
+
if (!tools[ref.id])
|
|
1042
|
+
missing.push(ref.id);
|
|
1043
|
+
}
|
|
1044
|
+
return missing;
|
|
1045
|
+
}
|
|
1046
|
+
snapshotConfiguredTools(config, tools) {
|
|
1047
|
+
if (!config)
|
|
1048
|
+
return null;
|
|
1049
|
+
const missing = this.getMissingCustomToolIds(config, tools);
|
|
1050
|
+
if (missing.length > 0) {
|
|
1051
|
+
throw new n8n_workflow_1.UserError(`Cannot publish agent with missing custom tools: ${missing.join(', ')}`);
|
|
1052
|
+
}
|
|
1053
|
+
const snapshot = {};
|
|
1054
|
+
for (const ref of config.tools ?? []) {
|
|
1055
|
+
if (ref.type !== 'custom')
|
|
1056
|
+
continue;
|
|
1057
|
+
const tool = tools[ref.id];
|
|
1058
|
+
if (tool)
|
|
1059
|
+
snapshot[ref.id] = tool;
|
|
1060
|
+
}
|
|
1061
|
+
return snapshot;
|
|
1062
|
+
}
|
|
1063
|
+
async reconstructFromConfig(agentEntity, credentialProvider, userId, integrationType) {
|
|
1064
|
+
const config = agentEntity.schema;
|
|
1065
|
+
if (!config) {
|
|
1066
|
+
throw new n8n_workflow_1.UserError('Agent has no JSON config.');
|
|
1067
|
+
}
|
|
1068
|
+
const toolsByName = {};
|
|
1069
|
+
for (const [_toolId, toolEntry] of Object.entries(agentEntity.tools ?? {})) {
|
|
1070
|
+
toolsByName[toolEntry.descriptor.name] = toolEntry.code;
|
|
1071
|
+
}
|
|
1072
|
+
const toolDescriptors = {};
|
|
1073
|
+
for (const [toolId, toolEntry] of Object.entries(agentEntity.tools ?? {})) {
|
|
1074
|
+
toolDescriptors[toolId] = toolEntry.descriptor;
|
|
1075
|
+
}
|
|
1076
|
+
const toolExecutor = this.secureRuntime.createToolExecutor(toolsByName);
|
|
1077
|
+
const toolResolver = this.makeToolResolver(agentEntity.projectId, userId);
|
|
1078
|
+
const resolvedTools = [];
|
|
1079
|
+
const reconstructed = await (0, from_json_config_1.buildFromJson)(config, toolDescriptors, {
|
|
1080
|
+
toolExecutor,
|
|
1081
|
+
credentialProvider,
|
|
1082
|
+
resolveTool: async (ref) => {
|
|
1083
|
+
const resolved = await toolResolver(ref);
|
|
1084
|
+
if (resolved)
|
|
1085
|
+
resolvedTools.push(resolved);
|
|
1086
|
+
return resolved;
|
|
1087
|
+
},
|
|
1088
|
+
skills: agentEntity.skills ?? {},
|
|
1089
|
+
memoryFactory: this.getMemoryFactory(),
|
|
1090
|
+
});
|
|
1091
|
+
await this.injectRuntimeDependencies({
|
|
1092
|
+
agent: reconstructed,
|
|
1093
|
+
agentId: agentEntity.id,
|
|
1094
|
+
projectId: agentEntity.projectId,
|
|
1095
|
+
credentialProvider,
|
|
1096
|
+
nodeToolsEnabled: this.shouldAttachNodeTools(config.config),
|
|
1097
|
+
integrationType,
|
|
1098
|
+
});
|
|
1099
|
+
const toolRegistry = (0, tool_registry_1.buildToolRegistry)(resolvedTools);
|
|
1100
|
+
return { agent: reconstructed, toolRegistry };
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
exports.AgentsService = AgentsService;
|
|
1104
|
+
__decorate([
|
|
1105
|
+
(0, decorators_1.OnPubSubEvent)('agent-config-changed', { instanceType: 'main' }),
|
|
1106
|
+
__metadata("design:type", Function),
|
|
1107
|
+
__metadata("design:paramtypes", [Object]),
|
|
1108
|
+
__metadata("design:returntype", void 0)
|
|
1109
|
+
], AgentsService.prototype, "handleAgentConfigChanged", null);
|
|
1110
|
+
exports.AgentsService = AgentsService = __decorate([
|
|
1111
|
+
(0, di_1.Service)(),
|
|
1112
|
+
__metadata("design:paramtypes", [backend_common_1.Logger,
|
|
1113
|
+
agent_repository_1.AgentRepository,
|
|
1114
|
+
db_1.ProjectRelationRepository,
|
|
1115
|
+
workflow_runner_1.WorkflowRunner,
|
|
1116
|
+
active_executions_1.ActiveExecutions,
|
|
1117
|
+
db_1.ExecutionRepository,
|
|
1118
|
+
db_1.WorkflowRepository,
|
|
1119
|
+
db_1.UserRepository,
|
|
1120
|
+
workflow_finder_service_1.WorkflowFinderService,
|
|
1121
|
+
url_service_1.UrlService,
|
|
1122
|
+
n8n_checkpoint_storage_1.N8NCheckpointStorage,
|
|
1123
|
+
agent_secure_runtime_1.AgentSecureRuntime,
|
|
1124
|
+
node_execution_1.EphemeralNodeExecutor,
|
|
1125
|
+
agents_tools_service_1.AgentsToolsService,
|
|
1126
|
+
n8n_memory_1.N8nMemory,
|
|
1127
|
+
agent_execution_service_1.AgentExecutionService,
|
|
1128
|
+
agent_published_version_repository_1.AgentPublishedVersionRepository,
|
|
1129
|
+
agent_skills_service_1.AgentSkillsService,
|
|
1130
|
+
publisher_service_1.Publisher,
|
|
1131
|
+
config_1.AgentsConfig,
|
|
1132
|
+
config_1.GlobalConfig])
|
|
1133
|
+
], AgentsService);
|
|
1134
|
+
//# sourceMappingURL=agents.service.js.map
|