n8n 2.27.2 → 2.28.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.js +0 -4
- package/dist/abstract-server.js.map +1 -1
- package/dist/active-workflow-manager.js +4 -1
- package/dist/active-workflow-manager.js.map +1 -1
- package/dist/agent-library-bundle.js +7 -3
- package/dist/build.tsbuildinfo +1 -1
- package/dist/commands/audit.js +6 -0
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/base-command.d.ts +1 -0
- package/dist/commands/base-command.js +36 -2
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/start.js +18 -9
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/worker.js +2 -0
- package/dist/commands/worker.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/controllers/api-keys.controller.d.ts +17 -0
- package/dist/controllers/api-keys.controller.js +19 -0
- package/dist/controllers/api-keys.controller.js.map +1 -1
- package/dist/controllers/e2e.controller.js +1 -0
- package/dist/controllers/e2e.controller.js.map +1 -1
- package/dist/controllers/telemetry.controller.d.ts +3 -1
- package/dist/controllers/telemetry.controller.js +17 -7
- package/dist/controllers/telemetry.controller.js.map +1 -1
- package/dist/controllers/users.controller.d.ts +1 -1
- package/dist/credentials/credentials.service.d.ts +5 -0
- package/dist/credentials/credentials.service.js +17 -3
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/evaluation.ee/evaluation-config.controller.d.ts +7 -1
- package/dist/evaluation.ee/evaluation-config.controller.js +30 -1
- package/dist/evaluation.ee/evaluation-config.controller.js.map +1 -1
- package/dist/evaluation.ee/evaluation-dataset.service.d.ts +24 -0
- package/dist/evaluation.ee/evaluation-dataset.service.js +185 -0
- package/dist/evaluation.ee/evaluation-dataset.service.js.map +1 -0
- package/dist/evaluation.ee/llm-judge-provider-registry.js +2 -2
- package/dist/evaluation.ee/llm-judge-provider-registry.js.map +1 -1
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +6 -6
- 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 +2 -0
- package/dist/evaluation.ee/test-runner/workflow-compiler.service.js +27 -0
- package/dist/evaluation.ee/test-runner/workflow-compiler.service.js.map +1 -1
- package/dist/eventbus/event-message-classes/index.d.ts +2 -2
- package/dist/eventbus/event-message-classes/index.js +2 -0
- package/dist/eventbus/event-message-classes/index.js.map +1 -1
- package/dist/events/event.service.d.ts +2 -1
- package/dist/events/event.service.js.map +1 -1
- package/dist/events/maps/instance-ai.event-map.d.ts +15 -0
- package/dist/events/maps/instance-ai.event-map.js +3 -0
- package/dist/events/maps/instance-ai.event-map.js.map +1 -0
- package/dist/events/maps/relay.event-map.d.ts +8 -1
- package/dist/events/relays/log-streaming.event-relay.d.ts +2 -0
- package/dist/events/relays/log-streaming.event-relay.js +26 -0
- package/dist/events/relays/log-streaming.event-relay.js.map +1 -1
- package/dist/events/relays/telemetry.event-relay.d.ts +1 -0
- package/dist/events/relays/telemetry.event-relay.js +11 -0
- package/dist/events/relays/telemetry.event-relay.js.map +1 -1
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js +1 -0
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
- package/dist/execution-lifecycle/shared/shared-hook-functions.d.ts +2 -1
- package/dist/execution-lifecycle/shared/shared-hook-functions.js +8 -3
- package/dist/execution-lifecycle/shared/shared-hook-functions.js.map +1 -1
- package/dist/executions/execution-data/azure-store.ee.d.ts +15 -0
- package/dist/executions/execution-data/azure-store.ee.js +116 -0
- package/dist/executions/execution-data/azure-store.ee.js.map +1 -0
- package/dist/executions/execution-data/db-store.d.ts +7 -0
- package/dist/executions/execution-data/db-store.js +21 -0
- package/dist/executions/execution-data/db-store.js.map +1 -1
- package/dist/executions/execution-data/types.d.ts +3 -0
- package/dist/executions/execution-persistence.d.ts +17 -3
- package/dist/executions/execution-persistence.js +121 -18
- package/dist/executions/execution-persistence.js.map +1 -1
- package/dist/executions/execution.service.d.ts +3 -1
- package/dist/executions/execution.service.js +10 -4
- package/dist/executions/execution.service.js.map +1 -1
- package/dist/executions/sum-binary-data-bytes.d.ts +2 -0
- package/dist/executions/sum-binary-data-bytes.js +46 -0
- package/dist/executions/sum-binary-data-bytes.js.map +1 -0
- package/dist/interfaces.d.ts +22 -0
- package/dist/license/license.service.d.ts +3 -1
- package/dist/license/license.service.js +36 -51
- package/dist/license/license.service.js.map +1 -1
- package/dist/metrics/prometheus/execution-data-metrics.service.js +2 -1
- package/dist/metrics/prometheus/execution-data-metrics.service.js.map +1 -1
- package/dist/metrics/prometheus/instance-ai-metrics.service.d.ts +12 -0
- package/dist/metrics/prometheus/instance-ai-metrics.service.js +101 -0
- package/dist/metrics/prometheus/instance-ai-metrics.service.js.map +1 -0
- package/dist/metrics/prometheus/instance-role-metrics.service.js +2 -2
- package/dist/metrics/prometheus/instance-role-metrics.service.js.map +1 -1
- package/dist/metrics/prometheus/prometheus.service.d.ts +4 -1
- package/dist/metrics/prometheus/prometheus.service.js +11 -2
- package/dist/metrics/prometheus/prometheus.service.js.map +1 -1
- package/dist/metrics/prometheus/webhook-and-form-metrics.service.d.ts +23 -0
- package/dist/metrics/prometheus/webhook-and-form-metrics.service.js +72 -0
- package/dist/metrics/prometheus/webhook-and-form-metrics.service.js.map +1 -0
- package/dist/metrics/prometheus/workflow-info-metrics.service.d.ts +12 -0
- package/dist/metrics/prometheus/workflow-info-metrics.service.js +66 -0
- package/dist/metrics/prometheus/workflow-info-metrics.service.js.map +1 -0
- package/dist/middlewares/body-parser.js +2 -2
- package/dist/middlewares/body-parser.js.map +1 -1
- package/dist/middlewares/list-query/dtos/workflow.filter.dto.d.ts +2 -0
- package/dist/middlewares/list-query/dtos/workflow.filter.dto.js +12 -0
- package/dist/middlewares/list-query/dtos/workflow.filter.dto.js.map +1 -1
- package/dist/modules/agents/agent-execution.service.d.ts +8 -1
- package/dist/modules/agents/agent-execution.service.js +26 -2
- package/dist/modules/agents/agent-execution.service.js.map +1 -1
- package/dist/modules/agents/agent-knowledge-commands.d.ts +27 -0
- package/dist/modules/agents/agent-knowledge-commands.js +415 -0
- package/dist/modules/agents/agent-knowledge-commands.js.map +1 -0
- package/dist/modules/agents/agent-knowledge-gate.d.ts +2 -0
- package/dist/modules/agents/agent-knowledge-gate.js +9 -0
- package/dist/modules/agents/agent-knowledge-gate.js.map +1 -0
- package/dist/modules/agents/agent-knowledge-retrieval.d.ts +184 -0
- package/dist/modules/agents/agent-knowledge-retrieval.js +172 -0
- package/dist/modules/agents/agent-knowledge-retrieval.js.map +1 -0
- package/dist/modules/agents/agent-knowledge-sandbox.service.d.ts +40 -0
- package/dist/modules/agents/agent-knowledge-sandbox.service.js +591 -0
- package/dist/modules/agents/agent-knowledge-sandbox.service.js.map +1 -0
- package/dist/modules/agents/agent-knowledge-storage.d.ts +21 -0
- package/dist/modules/agents/agent-knowledge-storage.js +89 -0
- package/dist/modules/agents/agent-knowledge-storage.js.map +1 -0
- package/dist/modules/agents/agent-knowledge.service.d.ts +25 -5
- package/dist/modules/agents/agent-knowledge.service.js +230 -7
- package/dist/modules/agents/agent-knowledge.service.js.map +1 -1
- package/dist/modules/agents/agent-runtime-reconstruction.service.d.ts +8 -2
- package/dist/modules/agents/agent-runtime-reconstruction.service.js +49 -11
- package/dist/modules/agents/agent-runtime-reconstruction.service.js.map +1 -1
- package/dist/modules/agents/agent-sandbox.controller.d.ts +18 -0
- package/dist/modules/agents/agent-sandbox.controller.js +71 -0
- package/dist/modules/agents/agent-sandbox.controller.js.map +1 -0
- package/dist/modules/agents/agent-telemetry.d.ts +5 -0
- package/dist/modules/agents/agent-telemetry.js +60 -0
- package/dist/modules/agents/agent-telemetry.js.map +1 -0
- package/dist/modules/agents/agents.controller.d.ts +4 -4
- package/dist/modules/agents/agents.controller.js +24 -23
- package/dist/modules/agents/agents.controller.js.map +1 -1
- package/dist/modules/agents/agents.module.d.ts +1 -1
- package/dist/modules/agents/agents.module.js +7 -1
- package/dist/modules/agents/agents.module.js.map +1 -1
- package/dist/modules/agents/agents.service.d.ts +5 -2
- package/dist/modules/agents/agents.service.js +68 -15
- package/dist/modules/agents/agents.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-prompts.d.ts +1 -1
- package/dist/modules/agents/builder/agents-builder-prompts.js +7 -0
- package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-settings.service.d.ts +12 -6
- package/dist/modules/agents/builder/agents-builder-settings.service.js +29 -12
- package/dist/modules/agents/builder/agents-builder-settings.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.d.ts +12 -4
- package/dist/modules/agents/builder/agents-builder-tools.service.js +118 -14
- package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder.service.d.ts +7 -0
- package/dist/modules/agents/builder/agents-builder.service.js +24 -6
- package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
- package/dist/modules/agents/builder/builder-tool-names.d.ts +1 -0
- package/dist/modules/agents/builder/builder-tool-names.js +1 -0
- package/dist/modules/agents/builder/builder-tool-names.js.map +1 -1
- package/dist/modules/agents/builder/from-ai-node-parameters.d.ts +7 -0
- package/dist/modules/agents/builder/from-ai-node-parameters.js +43 -0
- package/dist/modules/agents/builder/from-ai-node-parameters.js.map +1 -0
- package/dist/modules/agents/builder/get-resource-locator-options.tool.d.ts +10 -0
- package/dist/modules/agents/builder/get-resource-locator-options.tool.js +148 -0
- package/dist/modules/agents/builder/get-resource-locator-options.tool.js.map +1 -0
- package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -1
- package/dist/modules/agents/builder/prompts/tools.prompt.js +11 -0
- package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -1
- package/dist/modules/agents/builder/skills/index.js +2 -0
- package/dist/modules/agents/builder/skills/index.js.map +1 -1
- package/dist/modules/agents/builder/skills/resource-locators.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/resource-locators.skill.js +107 -0
- package/dist/modules/agents/builder/skills/resource-locators.skill.js.map +1 -0
- package/dist/modules/agents/builder/verify-mcp-server.tool.d.ts +2 -0
- package/dist/modules/agents/builder/verify-mcp-server.tool.js +1 -1
- package/dist/modules/agents/builder/verify-mcp-server.tool.js.map +1 -1
- package/dist/modules/agents/entities/agent-file.entity.d.ts +11 -0
- package/dist/modules/agents/entities/agent-file.entity.js +50 -0
- package/dist/modules/agents/entities/agent-file.entity.js.map +1 -0
- package/dist/modules/agents/execution-recorder.js +4 -7
- package/dist/modules/agents/execution-recorder.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +1 -1
- package/dist/modules/agents/integrations/agent-chat-bridge.js +7 -9
- package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-integration.d.ts +7 -3
- package/dist/modules/agents/integrations/agent-chat-integration.js +5 -0
- package/dist/modules/agents/integrations/agent-chat-integration.js.map +1 -1
- package/dist/modules/agents/integrations/integration-action-executor.d.ts +704 -0
- package/dist/modules/agents/integrations/integration-action-executor.js +36 -22
- package/dist/modules/agents/integrations/integration-action-executor.js.map +1 -1
- package/dist/modules/agents/integrations/integration-context-query-executor.js +23 -4
- package/dist/modules/agents/integrations/integration-context-query-executor.js.map +1 -1
- package/dist/modules/agents/integrations/integration-helpers.d.ts +12 -1
- package/dist/modules/agents/integrations/integration-helpers.js +17 -8
- package/dist/modules/agents/integrations/integration-helpers.js.map +1 -1
- package/dist/modules/agents/integrations/integration-message-context.service.js +2 -4
- package/dist/modules/agents/integrations/integration-message-context.service.js.map +1 -1
- package/dist/modules/agents/integrations/integration-tools.d.ts +11 -3
- package/dist/modules/agents/integrations/integration-tools.js +19 -118
- package/dist/modules/agents/integrations/integration-tools.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-integration.d.ts +3 -1
- package/dist/modules/agents/integrations/platforms/linear-integration.js +22 -6
- package/dist/modules/agents/integrations/platforms/linear-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-operations.js +19 -29
- package/dist/modules/agents/integrations/platforms/linear-operations.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.d.ts +20 -0
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.js +99 -0
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.d.ts +2 -1
- package/dist/modules/agents/integrations/platforms/slack-integration.js +5 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-operations.js +3 -2
- package/dist/modules/agents/integrations/platforms/slack-operations.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/telegram-integration.d.ts +11 -2
- package/dist/modules/agents/integrations/platforms/telegram-integration.js +43 -14
- package/dist/modules/agents/integrations/platforms/telegram-integration.js.map +1 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.d.ts +3 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.js +19 -11
- package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -1
- package/dist/modules/agents/json-config/from-json-config.d.ts +2 -1
- package/dist/modules/agents/json-config/from-json-config.js +11 -1
- package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
- package/dist/modules/agents/json-config/mcp-client-factory.d.ts +2 -0
- package/dist/modules/agents/json-config/mcp-client-factory.js +2 -2
- package/dist/modules/agents/json-config/mcp-client-factory.js.map +1 -1
- package/dist/modules/agents/repositories/agent-file.repository.d.ts +8 -0
- package/dist/modules/agents/repositories/agent-file.repository.js +38 -0
- package/dist/modules/agents/repositories/agent-file.repository.js.map +1 -0
- package/dist/modules/agents/sub-agents/sub-agent-foreground-runner.js +5 -0
- package/dist/modules/agents/sub-agents/sub-agent-foreground-runner.js.map +1 -1
- package/dist/modules/agents/tools/knowledge/search-knowledge.tool.d.ts +90 -0
- package/dist/modules/agents/tools/knowledge/search-knowledge.tool.js +209 -0
- package/dist/modules/agents/tools/knowledge/search-knowledge.tool.js.map +1 -0
- package/dist/modules/agents/tools/workflow-tool-factory.js +6 -8
- package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -1
- package/dist/modules/agents/tracing/builder-telemetry.d.ts +6 -1
- package/dist/modules/agents/tracing/builder-telemetry.js +26 -5
- package/dist/modules/agents/tracing/builder-telemetry.js.map +1 -1
- package/dist/modules/agents/utils/agent-memory-scope.d.ts +1 -0
- package/dist/modules/agents/utils/agent-memory-scope.js +6 -1
- package/dist/modules/agents/utils/agent-memory-scope.js.map +1 -1
- package/dist/modules/agents/utils/execution-to-message-mapper.js +54 -5
- package/dist/modules/agents/utils/execution-to-message-mapper.js.map +1 -1
- package/dist/modules/agents/utils/messages-envelope.d.ts +7 -0
- package/dist/modules/agents/utils/messages-envelope.js +97 -0
- package/dist/modules/agents/utils/messages-envelope.js.map +1 -0
- package/dist/modules/community-packages/community-packages.service.d.ts +3 -1
- package/dist/modules/community-packages/community-packages.service.js +17 -9
- package/dist/modules/community-packages/community-packages.service.js.map +1 -1
- package/dist/modules/community-packages/npm-utils.js +13 -6
- package/dist/modules/community-packages/npm-utils.js.map +1 -1
- package/dist/modules/data-table/multer-upload-middleware.d.ts +8 -1
- package/dist/modules/data-table/multer-upload-middleware.js +79 -30
- package/dist/modules/data-table/multer-upload-middleware.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/index.d.ts +2 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/index.js +19 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/index.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/metadata.d.ts +20 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/metadata.js +12 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/metadata.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-extractor.d.ts +12 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-extractor.js +85 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-extractor.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-seeder.d.ts +10 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-seeder.js +78 -0
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/n8n-oauth/n8n-oauth-seeder.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.d.ts +3 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js +17 -2
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.d.ts +4 -2
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js +20 -40
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.d.ts +21 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.js +77 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.d.ts +3 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js +18 -39
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.d.ts +4 -2
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js +46 -2
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js +3 -0
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/authorize-intent.service.d.ts +14 -0
- package/dist/modules/dynamic-credentials.ee/services/authorize-intent.service.js +39 -0
- package/dist/modules/dynamic-credentials.ee/services/authorize-intent.service.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-check-proxy.service.d.ts +7 -3
- package/dist/modules/dynamic-credentials.ee/services/credential-check-proxy.service.js +23 -21
- package/dist/modules/dynamic-credentials.ee/services/credential-check-proxy.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.d.ts +4 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js +111 -63
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +0 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/index.d.ts +1 -0
- package/dist/modules/dynamic-credentials.ee/services/index.js +1 -0
- package/dist/modules/dynamic-credentials.ee/services/index.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/aws-secrets-manager.d.ts +3 -1
- package/dist/modules/external-secrets.ee/providers/aws-secrets-manager.js +4 -1
- package/dist/modules/external-secrets.ee/providers/aws-secrets-manager.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/azure-key-vault/azure-key-vault.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/gcp-secrets-manager/gcp-secrets-manager.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/infisical.d.ts +4 -1
- package/dist/modules/external-secrets.ee/providers/infisical.js +45 -30
- package/dist/modules/external-secrets.ee/providers/infisical.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/one-password.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/vault.d.ts +5 -1
- package/dist/modules/external-secrets.ee/providers/vault.js +66 -61
- package/dist/modules/external-secrets.ee/providers/vault.js.map +1 -1
- package/dist/modules/insights/database/repositories/insights-by-period.repository.d.ts +2 -2
- package/dist/modules/insights/insights.service.d.ts +2 -2
- package/dist/modules/instance-ai/entities/index.d.ts +1 -0
- package/dist/modules/instance-ai/entities/index.js +3 -1
- package/dist/modules/instance-ai/entities/index.js.map +1 -1
- package/dist/modules/instance-ai/entities/instance-ai-thread-grant.entity.d.ts +9 -0
- package/dist/modules/instance-ai/entities/instance-ai-thread-grant.entity.js +45 -0
- package/dist/modules/instance-ai/entities/instance-ai-thread-grant.entity.js.map +1 -0
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.d.ts +3 -3
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js +2 -2
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js.map +1 -1
- package/dist/modules/instance-ai/eval/llm-wire-server.d.ts +2 -2
- package/dist/modules/instance-ai/eval/llm-wire-server.js +5 -5
- package/dist/modules/instance-ai/eval/llm-wire-server.js.map +1 -1
- package/dist/modules/instance-ai/eval/thread-credential-allowlist.service.d.ts +6 -0
- package/dist/modules/instance-ai/eval/thread-credential-allowlist.service.js +29 -0
- package/dist/modules/instance-ai/eval/thread-credential-allowlist.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-credit.service.d.ts +26 -0
- package/dist/modules/instance-ai/instance-ai-credit.service.js +210 -0
- package/dist/modules/instance-ai/instance-ai-credit.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-model.service.d.ts +20 -0
- package/dist/modules/instance-ai/instance-ai-model.service.js +135 -0
- package/dist/modules/instance-ai/instance-ai-model.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-run-probe.d.ts +5 -0
- package/dist/modules/instance-ai/instance-ai-run-probe.js +26 -0
- package/dist/modules/instance-ai/instance-ai-run-probe.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +2 -0
- package/dist/modules/instance-ai/instance-ai-settings.service.js +12 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-temporary-workflow.service.d.ts +15 -0
- package/dist/modules/instance-ai/instance-ai-temporary-workflow.service.js +140 -0
- package/dist/modules/instance-ai/instance-ai-temporary-workflow.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +4 -2
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +69 -10
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.controller.d.ts +20 -2
- package/dist/modules/instance-ai/instance-ai.controller.js +62 -4
- package/dist/modules/instance-ai/instance-ai.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +2 -1
- package/dist/modules/instance-ai/instance-ai.module.js +3 -0
- package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +42 -22
- package/dist/modules/instance-ai/instance-ai.service.js +408 -379
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/internal-messages.d.ts +4 -0
- package/dist/modules/instance-ai/internal-messages.js +24 -3
- package/dist/modules/instance-ai/internal-messages.js.map +1 -1
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-connection.controller.d.ts +1 -1
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-connection.controller.js +2 -6
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-connection.controller.js.map +1 -1
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-registry.service.d.ts +6 -1
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-registry.service.js +52 -2
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-registry.service.js.map +1 -1
- package/dist/modules/instance-ai/message-parser.js +2 -0
- package/dist/modules/instance-ai/message-parser.js.map +1 -1
- package/dist/modules/instance-ai/observability.d.ts +13 -0
- package/dist/modules/instance-ai/observability.js +23 -0
- package/dist/modules/instance-ai/observability.js.map +1 -0
- package/dist/modules/instance-ai/repositories/index.d.ts +1 -0
- package/dist/modules/instance-ai/repositories/index.js +3 -1
- package/dist/modules/instance-ai/repositories/index.js.map +1 -1
- package/dist/modules/instance-ai/repositories/instance-ai-thread-grant.repository.d.ts +7 -0
- package/dist/modules/instance-ai/repositories/instance-ai-thread-grant.repository.js +40 -0
- package/dist/modules/instance-ai/repositories/instance-ai-thread-grant.repository.js.map +1 -0
- package/dist/modules/instance-ai/sandbox/instance-ai-sandbox.service.js +2 -1
- package/dist/modules/instance-ai/sandbox/instance-ai-sandbox.service.js.map +1 -1
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js +4 -6
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js.map +1 -1
- package/dist/modules/instance-ai/web-research/fetch-and-extract.d.ts +2 -3
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js +34 -44
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js.map +1 -1
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.d.ts +2 -1
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.js +2 -2
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.js.map +1 -1
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.d.ts +8 -8
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.js +43 -60
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.js.map +1 -1
- package/dist/modules/log-streaming.ee/log-streaming-destination.service.d.ts +3 -1
- package/dist/modules/log-streaming.ee/log-streaming-destination.service.js +6 -3
- package/dist/modules/log-streaming.ee/log-streaming-destination.service.js.map +1 -1
- package/dist/modules/log-streaming.ee/log-streaming.controller.d.ts +3 -1
- package/dist/modules/log-streaming.ee/log-streaming.controller.js +6 -3
- package/dist/modules/log-streaming.ee/log-streaming.controller.js.map +1 -1
- package/dist/modules/mcp/dto/update-allowed-redirect-uris.dto.d.ts +9 -0
- package/dist/modules/mcp/dto/update-allowed-redirect-uris.dto.js +35 -0
- package/dist/modules/mcp/dto/update-allowed-redirect-uris.dto.js.map +1 -0
- package/dist/modules/mcp/mcp-protected-resource.d.ts +4 -1
- package/dist/modules/mcp/mcp-protected-resource.js +9 -3
- package/dist/modules/mcp/mcp-protected-resource.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +5 -2
- package/dist/modules/mcp/mcp.service.js +8 -3
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/mcp.settings.controller.d.ts +7 -0
- package/dist/modules/mcp/mcp.settings.controller.js +24 -0
- package/dist/modules/mcp/mcp.settings.controller.js.map +1 -1
- package/dist/modules/mcp/mcp.settings.service.d.ts +2 -0
- package/dist/modules/mcp/mcp.settings.service.js +15 -0
- package/dist/modules/mcp/mcp.settings.service.js.map +1 -1
- package/dist/modules/mcp/mcp.typeguards.d.ts +0 -1
- package/dist/modules/mcp/mcp.typeguards.js +9 -12
- package/dist/modules/mcp/mcp.typeguards.js.map +1 -1
- package/dist/modules/mcp/mcp.utils.js +2 -1
- package/dist/modules/mcp/mcp.utils.js.map +1 -1
- package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +10 -8
- package/dist/modules/mcp/tools/execute-workflow.tool.js +25 -13
- package/dist/modules/mcp/tools/execute-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/get-workflow-details.tool.js +2 -0
- package/dist/modules/mcp/tools/get-workflow-details.tool.js.map +1 -1
- package/dist/modules/mcp/tools/schemas.d.ts +128 -0
- package/dist/modules/mcp/tools/schemas.js +9 -0
- package/dist/modules/mcp/tools/schemas.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +15 -4
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/credential-validation.d.ts +13 -2
- package/dist/modules/mcp/tools/workflow-builder/credential-validation.js +144 -23
- package/dist/modules/mcp/tools/workflow-builder/credential-validation.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +23 -6
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.d.ts +31 -1
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js +22 -0
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js.map +1 -1
- package/dist/modules/n8n-packages/engine/import-pipeline.js +40 -19
- package/dist/modules/n8n-packages/engine/import-pipeline.js.map +1 -1
- package/dist/modules/n8n-packages/entities/credential/credential-importer.d.ts +8 -4
- package/dist/modules/n8n-packages/entities/credential/credential-importer.js +40 -6
- package/dist/modules/n8n-packages/entities/credential/credential-importer.js.map +1 -1
- package/dist/modules/n8n-packages/entities/credential/credential-matcher.d.ts +7 -3
- package/dist/modules/n8n-packages/entities/credential/credential-matcher.js +30 -5
- package/dist/modules/n8n-packages/entities/credential/credential-matcher.js.map +1 -1
- package/dist/modules/n8n-packages/entities/credential/credential-missing-mode.d.ts +3 -0
- package/dist/modules/n8n-packages/entities/credential/credential-missing-mode.js +17 -0
- package/dist/modules/n8n-packages/entities/credential/credential-missing-mode.js.map +1 -1
- package/dist/modules/n8n-packages/entities/credential/credential.types.d.ts +10 -4
- package/dist/modules/n8n-packages/entities/credential/credential.types.js +2 -0
- package/dist/modules/n8n-packages/entities/credential/credential.types.js.map +1 -1
- package/dist/modules/n8n-packages/entities/credential/id-based-credential-matcher.d.ts +3 -4
- package/dist/modules/n8n-packages/entities/credential/id-based-credential-matcher.js +10 -11
- package/dist/modules/n8n-packages/entities/credential/id-based-credential-matcher.js.map +1 -1
- package/dist/modules/n8n-packages/entities/workflow/workflow-import.types.d.ts +6 -6
- package/dist/modules/n8n-packages/entities/workflow/workflow-importer.d.ts +3 -3
- package/dist/modules/n8n-packages/entities/workflow/workflow-importer.js +12 -10
- package/dist/modules/n8n-packages/entities/workflow/workflow-importer.js.map +1 -1
- package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.d.ts +6 -2
- package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.js +33 -11
- package/dist/modules/n8n-packages/entities/workflow/workflow-publisher.js.map +1 -1
- package/dist/modules/n8n-packages/entities/workflow/workflow-publishing-policy.types.d.ts +8 -0
- package/dist/modules/n8n-packages/n8n-packages.types.d.ts +23 -3
- package/dist/modules/n8n-packages/n8n-packages.types.js.map +1 -1
- package/dist/modules/oauth-jwe/oauth-jwe.schemas.d.ts +12 -12
- package/dist/modules/oauth-server/oauth-consent.controller.js +1 -0
- package/dist/modules/oauth-server/oauth-consent.controller.js.map +1 -1
- package/dist/modules/oauth-server/oauth-consent.service.d.ts +1 -0
- package/dist/modules/oauth-server/oauth-consent.service.js +2 -0
- package/dist/modules/oauth-server/oauth-consent.service.js.map +1 -1
- package/dist/modules/oauth-server/oauth-server.module.js +1 -1
- package/dist/modules/oauth-server/oauth-server.module.js.map +1 -1
- package/dist/modules/oauth-server/oauth-server.service.d.ts +2 -0
- package/dist/modules/oauth-server/oauth-server.service.js +48 -1
- package/dist/modules/oauth-server/oauth-server.service.js.map +1 -1
- package/dist/modules/oauth-server/oauth.controller.js +4 -1
- package/dist/modules/oauth-server/oauth.controller.js.map +1 -1
- package/dist/modules/otel/otel.service.d.ts +3 -1
- package/dist/modules/otel/otel.service.js +6 -3
- package/dist/modules/otel/otel.service.js.map +1 -1
- package/dist/modules/quick-connect/handlers/firecrawl.handler.d.ts +3 -0
- package/dist/modules/quick-connect/handlers/firecrawl.handler.js +20 -7
- package/dist/modules/quick-connect/handlers/firecrawl.handler.js.map +1 -1
- package/dist/modules/quick-connect/quick-connect.config.d.ts +17 -17
- package/dist/modules/quick-connect/quick-connect.module.d.ts +3 -3
- package/dist/modules/source-control.ee/source-control-import.service.ee.js +1 -1
- package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +4 -4
- package/dist/modules/source-control.ee/source-control.service.ee.d.ts +2 -2
- package/dist/modules/sso-oidc/oidc.service.ee.d.ts +3 -1
- package/dist/modules/sso-oidc/oidc.service.ee.js +15 -25
- package/dist/modules/sso-oidc/oidc.service.ee.js.map +1 -1
- package/dist/modules/sso-saml/saml.service.ee.d.ts +3 -1
- package/dist/modules/sso-saml/saml.service.ee.js +15 -15
- package/dist/modules/sso-saml/saml.service.ee.js.map +1 -1
- package/dist/modules/token-exchange/services/jwks-resolver.d.ts +3 -1
- package/dist/modules/token-exchange/services/jwks-resolver.js +11 -3
- package/dist/modules/token-exchange/services/jwks-resolver.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +8 -3
- package/dist/oauth/oauth.service.js +106 -47
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/oauth/types.d.ts +1 -1
- package/dist/oauth/types.js.map +1 -1
- package/dist/posthog/index.js +4 -3
- package/dist/posthog/index.js.map +1 -1
- package/dist/public-api/index.js +46 -3
- package/dist/public-api/index.js.map +1 -1
- package/dist/public-api/swagger-theme.css +14 -0
- package/dist/public-api/types.d.ts +2 -0
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js +1 -1
- package/dist/public-api/v1/handlers/credentials/credentials.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js +4 -3
- package/dist/public-api/v1/handlers/data-tables/data-tables.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/discover/discover.service.js +9 -11
- package/dist/public-api/v1/handlers/discover/discover.service.js.map +1 -1
- package/dist/public-api/v1/handlers/executions/executions.handler.js +8 -4
- package/dist/public-api/v1/handlers/executions/executions.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js +3 -1
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
- package/dist/public-api/v1/handlers/workflows/workflows.service.d.ts +1 -2
- package/dist/public-api/v1/handlers/workflows/workflows.service.js +3 -2
- package/dist/public-api/v1/handlers/workflows/workflows.service.js.map +1 -1
- package/dist/public-api/v1/openapi.yml +124 -2
- package/dist/response-helper.d.ts +2 -1
- package/dist/response-helper.js +2 -17
- package/dist/response-helper.js.map +1 -1
- package/dist/scaling/constants.d.ts +2 -2
- package/dist/scaling/constants.js +3 -0
- package/dist/scaling/constants.js.map +1 -1
- package/dist/scaling/execution-stop.service.d.ts +15 -0
- package/dist/scaling/execution-stop.service.js +59 -0
- package/dist/scaling/execution-stop.service.js.map +1 -0
- package/dist/scaling/job-processor.js +8 -2
- package/dist/scaling/job-processor.js.map +1 -1
- package/dist/scaling/multi-main-setup.ee.d.ts +1 -0
- package/dist/scaling/multi-main-setup.ee.js +6 -6
- package/dist/scaling/multi-main-setup.ee.js.map +1 -1
- package/dist/scaling/pubsub/pubsub.event-map.d.ts +4 -0
- package/dist/scaling/pubsub/pubsub.types.d.ts +3 -1
- package/dist/security-audit/risk-reporters/instance-risk-reporter.d.ts +3 -1
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js +27 -20
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/services/ai-gateway.service.d.ts +5 -1
- package/dist/services/ai-gateway.service.js +53 -32
- package/dist/services/ai-gateway.service.js.map +1 -1
- package/dist/services/ai-workflow-builder.service.d.ts +4 -3
- package/dist/services/ai-workflow-builder.service.js +9 -5
- package/dist/services/ai-workflow-builder.service.js.map +1 -1
- package/dist/services/credentials-tester.service.js +16 -15
- package/dist/services/credentials-tester.service.js.map +1 -1
- package/dist/services/dynamic-templates.service.d.ts +3 -1
- package/dist/services/dynamic-templates.service.js +13 -9
- package/dist/services/dynamic-templates.service.js.map +1 -1
- package/dist/services/frontend.service.d.ts +6 -1
- package/dist/services/frontend.service.js +39 -2
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/services/node-resource-explorer.service.js +4 -22
- package/dist/services/node-resource-explorer.service.js.map +1 -1
- package/dist/services/project.service.ee.d.ts +3 -2
- package/dist/services/project.service.ee.js +14 -3
- package/dist/services/project.service.ee.js.map +1 -1
- package/dist/services/protected-resource.registry.d.ts +1 -0
- package/dist/services/protected-resource.registry.js.map +1 -1
- package/dist/services/public-api-key.service.d.ts +6 -2
- package/dist/services/public-api-key.service.js +56 -10
- package/dist/services/public-api-key.service.js.map +1 -1
- package/dist/services/role.service.d.ts +2 -2
- package/dist/services/role.service.js.map +1 -1
- package/dist/services/trigger-auth-identity-seeder-proxy.service.d.ts +10 -0
- package/dist/services/trigger-auth-identity-seeder-proxy.service.js +33 -0
- package/dist/services/trigger-auth-identity-seeder-proxy.service.js.map +1 -0
- package/dist/services/workflow-statistics.service.d.ts +3 -13
- package/dist/services/workflow-statistics.service.js +77 -64
- package/dist/services/workflow-statistics.service.js.map +1 -1
- package/dist/task-runners/task-broker/task-broker-server.js +2 -1
- package/dist/task-runners/task-broker/task-broker-server.js.map +1 -1
- package/dist/task-runners/task-runner-module.js +2 -0
- package/dist/task-runners/task-runner-module.js.map +1 -1
- package/dist/telemetry/index.d.ts +25 -2
- package/dist/telemetry/index.js +80 -12
- package/dist/telemetry/index.js.map +1 -1
- package/dist/utils/ai-proxy-fetch.d.ts +3 -0
- package/dist/utils/ai-proxy-fetch.js +27 -0
- package/dist/utils/ai-proxy-fetch.js.map +1 -0
- package/dist/utils/auth-fetch.d.ts +3 -1
- package/dist/utils/auth-fetch.js +3 -4
- package/dist/utils/auth-fetch.js.map +1 -1
- package/dist/utils/strapi-utils.d.ts +8 -4
- package/dist/utils/strapi-utils.js +25 -9
- package/dist/utils/strapi-utils.js.map +1 -1
- package/dist/webhooks/live-webhooks.js +1 -0
- package/dist/webhooks/live-webhooks.js.map +1 -1
- package/dist/webhooks/test-webhooks.controller.d.ts +8 -0
- package/dist/webhooks/test-webhooks.controller.js +39 -0
- package/dist/webhooks/test-webhooks.controller.js.map +1 -0
- package/dist/webhooks/webhook-form-data.js +9 -1
- package/dist/webhooks/webhook-form-data.js.map +1 -1
- package/dist/webhooks/webhook-helpers.js +16 -0
- package/dist/webhooks/webhook-helpers.js.map +1 -1
- package/dist/webhooks/webhook-request-handler.js +35 -0
- package/dist/webhooks/webhook-request-handler.js.map +1 -1
- package/dist/workflow-execute-additional-data.js +15 -0
- package/dist/workflow-execute-additional-data.js.map +1 -1
- package/dist/workflow-helpers.d.ts +7 -2
- package/dist/workflow-helpers.js +50 -1
- package/dist/workflow-helpers.js.map +1 -1
- package/dist/workflows/publication/publication-result.d.ts +2 -0
- package/dist/workflows/publication/publication-status-reporter.d.ts +1 -0
- package/dist/workflows/publication/publication-status-reporter.js +22 -1
- package/dist/workflows/publication/publication-status-reporter.js.map +1 -1
- package/dist/workflows/publication/published-workflow-enqueuer.d.ts +13 -0
- package/dist/workflows/publication/published-workflow-enqueuer.js +53 -0
- package/dist/workflows/publication/published-workflow-enqueuer.js.map +1 -0
- package/dist/workflows/publication/published-workflow-trigger-deactivator.d.ts +16 -0
- package/dist/workflows/publication/published-workflow-trigger-deactivator.js +79 -0
- package/dist/workflows/publication/published-workflow-trigger-deactivator.js.map +1 -0
- package/dist/workflows/publication/workflow-publication-applier.d.ts +6 -1
- package/dist/workflows/publication/workflow-publication-applier.js +39 -3
- package/dist/workflows/publication/workflow-publication-applier.js.map +1 -1
- package/dist/workflows/publication/workflow-publication-lifecycle-lock.d.ts +13 -0
- package/dist/workflows/publication/workflow-publication-lifecycle-lock.js +104 -0
- package/dist/workflows/publication/workflow-publication-lifecycle-lock.js.map +1 -0
- package/dist/workflows/publication/workflow-publication-outbox-cleanup.service.d.ts +19 -0
- package/dist/workflows/publication/workflow-publication-outbox-cleanup.service.js +109 -0
- package/dist/workflows/publication/workflow-publication-outbox-cleanup.service.js.map +1 -0
- package/dist/workflows/publication/workflow-publication-outbox-consumer.d.ts +11 -4
- package/dist/workflows/publication/workflow-publication-outbox-consumer.js +105 -45
- package/dist/workflows/publication/workflow-publication-outbox-consumer.js.map +1 -1
- package/dist/workflows/triggers/non-webhook-trigger-registrar.d.ts +4 -5
- package/dist/workflows/triggers/non-webhook-trigger-registrar.js +30 -9
- package/dist/workflows/triggers/non-webhook-trigger-registrar.js.map +1 -1
- package/dist/workflows/triggers/trigger-activation-retry.d.ts +2 -0
- package/dist/workflows/triggers/trigger-activation-retry.js +23 -0
- package/dist/workflows/triggers/trigger-activation-retry.js.map +1 -0
- package/dist/workflows/triggers/webhook-trigger-registrar.d.ts +3 -2
- package/dist/workflows/triggers/webhook-trigger-registrar.js +60 -32
- package/dist/workflows/triggers/webhook-trigger-registrar.js.map +1 -1
- package/dist/workflows/triggers/workflow-trigger-activator.d.ts +6 -3
- package/dist/workflows/triggers/workflow-trigger-activator.js +126 -60
- package/dist/workflows/triggers/workflow-trigger-activator.js.map +1 -1
- package/dist/workflows/workflow-creation.service.d.ts +1 -0
- package/dist/workflows/workflow-creation.service.js +17 -8
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow-entity-mapper.d.ts +5 -0
- package/dist/workflows/workflow-entity-mapper.js +22 -0
- package/dist/workflows/workflow-entity-mapper.js.map +1 -0
- package/dist/workflows/workflow-execution.service.d.ts +6 -2
- package/dist/workflows/workflow-execution.service.js +36 -13
- package/dist/workflows/workflow-execution.service.js.map +1 -1
- package/dist/workflows/workflow-history/workflow-history.service.js +1 -0
- package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
- package/dist/workflows/workflow-published-data.service.d.ts +1 -3
- package/dist/workflows/workflow-published-data.service.js +2 -9
- package/dist/workflows/workflow-published-data.service.js.map +1 -1
- package/dist/workflows/workflow-validation.service.js +2 -1
- package/dist/workflows/workflow-validation.service.js.map +1 -1
- package/dist/workflows/workflow.service.d.ts +4 -3
- package/dist/workflows/workflow.service.js +72 -33
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.d.ts +3 -2
- package/dist/workflows/workflows.controller.js +12 -23
- package/dist/workflows/workflows.controller.js.map +1 -1
- package/package.json +59 -41
- package/templates/form-trigger.handlebars +8 -1
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.InstanceAiService = void 0;
|
|
46
46
|
const api_types_1 = require("@n8n/api-types");
|
|
47
47
|
const backend_common_1 = require("@n8n/backend-common");
|
|
48
|
+
const backend_network_1 = require("@n8n/backend-network");
|
|
48
49
|
const config_1 = require("@n8n/config");
|
|
49
50
|
const db_1 = require("@n8n/db");
|
|
50
51
|
const decorators_1 = require("@n8n/decorators");
|
|
@@ -55,41 +56,62 @@ const n8n_core_1 = require("n8n-core");
|
|
|
55
56
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
56
57
|
const nanoid_1 = require("nanoid");
|
|
57
58
|
const uuid_1 = require("uuid");
|
|
59
|
+
const constants_1 = require("../../constants");
|
|
60
|
+
const event_service_1 = require("../../events/event.service");
|
|
61
|
+
const source_control_preferences_service_ee_1 = require("../../modules/source-control.ee/source-control-preferences.service.ee");
|
|
62
|
+
const ai_service_1 = require("../../services/ai.service");
|
|
63
|
+
const proxy_token_manager_1 = require("../../services/proxy-token-manager");
|
|
64
|
+
const url_service_1 = require("../../services/url.service");
|
|
65
|
+
const telemetry_1 = require("../../telemetry");
|
|
66
|
+
const thread_credential_allowlist_service_1 = require("./eval/thread-credential-allowlist.service");
|
|
58
67
|
const in_process_event_bus_1 = require("./event-bus/in-process-event-bus");
|
|
68
|
+
const instance_ai_credit_service_1 = require("./instance-ai-credit.service");
|
|
59
69
|
const instance_ai_gateway_service_1 = require("./instance-ai-gateway.service");
|
|
60
70
|
const instance_ai_memory_service_1 = require("./instance-ai-memory.service");
|
|
71
|
+
const instance_ai_model_service_1 = require("./instance-ai-model.service");
|
|
72
|
+
const instance_ai_run_probe_1 = require("./instance-ai-run-probe");
|
|
61
73
|
const instance_ai_settings_service_1 = require("./instance-ai-settings.service");
|
|
74
|
+
const instance_ai_temporary_workflow_service_1 = require("./instance-ai-temporary-workflow.service");
|
|
62
75
|
const instance_ai_adapter_service_1 = require("./instance-ai.adapter.service");
|
|
63
|
-
const output_redaction_config_1 = require("./output-redaction-config");
|
|
64
76
|
const internal_messages_1 = require("./internal-messages");
|
|
65
77
|
const liveness_1 = require("./liveness");
|
|
66
78
|
const mcp_1 = require("./mcp");
|
|
79
|
+
const observability_1 = require("./observability");
|
|
80
|
+
const output_redaction_config_1 = require("./output-redaction-config");
|
|
81
|
+
const planned_task_action_runner_1 = require("./planned-task-action-runner");
|
|
67
82
|
const instance_ai_pending_confirmation_repository_1 = require("./repositories/instance-ai-pending-confirmation.repository");
|
|
68
|
-
const
|
|
69
|
-
const sandbox_1 = require("./sandbox");
|
|
70
|
-
const suspended_run_restorer_service_1 = require("./suspended-run-restorer.service");
|
|
71
|
-
const suspended_thread_persistence_service_1 = require("./suspended-thread-persistence.service");
|
|
83
|
+
const instance_ai_thread_grant_repository_1 = require("./repositories/instance-ai-thread-grant.repository");
|
|
72
84
|
const run_trace_metadata_1 = require("./run-trace-metadata");
|
|
85
|
+
const sandbox_1 = require("./sandbox");
|
|
73
86
|
const db_iteration_log_storage_1 = require("./storage/db-iteration-log-storage");
|
|
74
87
|
const db_snapshot_storage_1 = require("./storage/db-snapshot-storage");
|
|
75
88
|
const typeorm_agent_checkpoint_store_1 = require("./storage/typeorm-agent-checkpoint-store");
|
|
76
89
|
const typeorm_agent_memory_1 = require("./storage/typeorm-agent-memory");
|
|
90
|
+
const suspended_run_restorer_service_1 = require("./suspended-run-restorer.service");
|
|
91
|
+
const suspended_thread_persistence_service_1 = require("./suspended-thread-persistence.service");
|
|
77
92
|
const trace_replay_state_1 = require("./trace-replay-state");
|
|
78
93
|
const workflow_verification_obligation_service_1 = require("./workflow-verification-obligation-service");
|
|
79
|
-
const planned_task_action_runner_1 = require("./planned-task-action-runner");
|
|
80
94
|
const workflow_verification_task_projector_1 = require("./workflow-verification-task-projector");
|
|
81
|
-
const constants_1 = require("../../constants");
|
|
82
|
-
const event_service_1 = require("../../events/event.service");
|
|
83
|
-
const source_control_preferences_service_ee_1 = require("../../modules/source-control.ee/source-control-preferences.service.ee");
|
|
84
|
-
const push_1 = require("../../push");
|
|
85
|
-
const ai_service_1 = require("../../services/ai.service");
|
|
86
|
-
const proxy_token_manager_1 = require("../../services/proxy-token-manager");
|
|
87
|
-
const url_service_1 = require("../../services/url.service");
|
|
88
|
-
const telemetry_1 = require("../../telemetry");
|
|
89
|
-
const backend_network_1 = require("@n8n/backend-network");
|
|
90
95
|
function getErrorMessage(error) {
|
|
91
96
|
return error instanceof Error ? error.message : String(error);
|
|
92
97
|
}
|
|
98
|
+
function buildContextResourcesBlock(workflowAttachments) {
|
|
99
|
+
if (workflowAttachments.length === 0)
|
|
100
|
+
return '';
|
|
101
|
+
const lines = workflowAttachments.map((attachment) => {
|
|
102
|
+
const name = attachment.name ? ` "${attachment.name}"` : '';
|
|
103
|
+
const execution = attachment.executionId
|
|
104
|
+
? `, currently viewing its execution \`${attachment.executionId}\``
|
|
105
|
+
: '';
|
|
106
|
+
return `- Workflow${name} (id: \`${attachment.id}\`)${execution}.`;
|
|
107
|
+
});
|
|
108
|
+
const prose = [
|
|
109
|
+
'The user opened this conversation from the workflow editor, where they are looking at:',
|
|
110
|
+
...lines,
|
|
111
|
+
"Treat this purely as context. Until the user tells you what they need, don't read, inspect, run, or otherwise call tools on these resources, and don't make claims about their contents — just briefly acknowledge what they're working on and ask how you can help.",
|
|
112
|
+
].join('\n');
|
|
113
|
+
return `${internal_messages_1.EDITOR_CONTEXT_OPEN_TAG}\n${JSON.stringify(workflowAttachments)}\n\n${prose}\n${internal_messages_1.EDITOR_CONTEXT_CLOSE_TAG}`;
|
|
114
|
+
}
|
|
93
115
|
function isTelemetryConfigurableAgent(agent) {
|
|
94
116
|
return (typeof agent === 'object' &&
|
|
95
117
|
agent !== null &&
|
|
@@ -224,21 +246,10 @@ function buildPlannedTaskConversationContext(task, graph) {
|
|
|
224
246
|
}
|
|
225
247
|
return parts.join('\n');
|
|
226
248
|
}
|
|
227
|
-
function getProxyFetch() {
|
|
228
|
-
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
|
229
|
-
if (!proxyUrl)
|
|
230
|
-
return undefined;
|
|
231
|
-
const { ProxyAgent } = require('undici');
|
|
232
|
-
const dispatcher = new ProxyAgent(proxyUrl);
|
|
233
|
-
return (async (url, init) => await globalThis.fetch(url, {
|
|
234
|
-
...init,
|
|
235
|
-
dispatcher,
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
249
|
function toConfirmationData(request) {
|
|
239
250
|
switch (request.kind) {
|
|
240
251
|
case 'approval':
|
|
241
|
-
return { approved: request.approved, userInput: request.userInput };
|
|
252
|
+
return { approved: request.approved, userInput: request.userInput, scope: request.scope };
|
|
242
253
|
case 'domainAccessApprove':
|
|
243
254
|
return { approved: true, domainAccessAction: request.domainAccessAction };
|
|
244
255
|
case 'domainAccessDeny':
|
|
@@ -275,7 +286,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
275
286
|
}
|
|
276
287
|
return this._mcpClientManager;
|
|
277
288
|
}
|
|
278
|
-
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, gatewayService, memoryService, agentMemory, checkpointStore, aiService,
|
|
289
|
+
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, gatewayService, memoryService, agentMemory, checkpointStore, aiService, threadGrantRepo, pendingConfirmationRepo, urlService, dbSnapshotStorage, dbIterationLogStorage, sourceControlPreferencesService, telemetry, mcpRegistryService, userRepository, temporaryWorkflowService, errorReporter, ssrfProtectionConfig, ssrfProtectionService, eventService, evalCredentialAllowlists, runProbe, modelService, creditService) {
|
|
279
290
|
this.instanceSettings = instanceSettings;
|
|
280
291
|
this.adapterService = adapterService;
|
|
281
292
|
this.eventBus = eventBus;
|
|
@@ -285,8 +296,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
285
296
|
this.agentMemory = agentMemory;
|
|
286
297
|
this.checkpointStore = checkpointStore;
|
|
287
298
|
this.aiService = aiService;
|
|
288
|
-
this.
|
|
289
|
-
this.threadRepo = threadRepo;
|
|
299
|
+
this.threadGrantRepo = threadGrantRepo;
|
|
290
300
|
this.pendingConfirmationRepo = pendingConfirmationRepo;
|
|
291
301
|
this.urlService = urlService;
|
|
292
302
|
this.dbSnapshotStorage = dbSnapshotStorage;
|
|
@@ -295,25 +305,31 @@ let InstanceAiService = class InstanceAiService {
|
|
|
295
305
|
this.telemetry = telemetry;
|
|
296
306
|
this.mcpRegistryService = mcpRegistryService;
|
|
297
307
|
this.userRepository = userRepository;
|
|
298
|
-
this.
|
|
308
|
+
this.temporaryWorkflowService = temporaryWorkflowService;
|
|
299
309
|
this.errorReporter = errorReporter;
|
|
300
310
|
this.eventService = eventService;
|
|
311
|
+
this.evalCredentialAllowlists = evalCredentialAllowlists;
|
|
312
|
+
this.modelService = modelService;
|
|
313
|
+
this.creditService = creditService;
|
|
301
314
|
this.runState = new instance_ai_1.RunStateRegistry();
|
|
302
315
|
this.backgroundTasks = new instance_ai_1.BackgroundTaskManager(MAX_CONCURRENT_BACKGROUND_TASKS_PER_THREAD);
|
|
316
|
+
this.memoryTaskRegistry = new instance_ai_1.MemoryTaskRegistry();
|
|
303
317
|
this.traceContextsByRunId = new Map();
|
|
318
|
+
this.reportedErrors = new WeakSet();
|
|
304
319
|
this.domainAccessTrackersByThread = new Map();
|
|
305
320
|
this.threadPushRef = new Map();
|
|
306
321
|
this.planRequestsByThread = new Map();
|
|
307
322
|
this.schedulerLocks = new Map();
|
|
308
323
|
this.pendingCheckpointReentries = new Map();
|
|
309
324
|
this.pendingTerminalOutcomes = new Map();
|
|
310
|
-
this.creditedThreads = new Set();
|
|
311
325
|
this.traceReplay = new trace_replay_state_1.TraceReplayState();
|
|
326
|
+
this.runDebugBuffer = new instance_ai_1.RunDebugBuffer();
|
|
312
327
|
this.checkpointPruningStopped = true;
|
|
313
328
|
this.inFlightExecutions = new Set();
|
|
314
329
|
this.preserveHitlOnShutdown = new Set();
|
|
315
330
|
this.userMessagePersistenceByRun = new Map();
|
|
316
331
|
this.logger = logger.scoped('instance-ai');
|
|
332
|
+
runProbe.registerActiveRunCountProvider(() => this.runState.activeRunCount());
|
|
317
333
|
this.workflowObligations = new workflow_verification_obligation_service_1.WorkflowVerificationObligationService(this.agentMemory);
|
|
318
334
|
this.taskProjector = new workflow_verification_task_projector_1.WorkflowVerificationTaskProjector(this.agentMemory, this.eventBus, this.logger, this.workflowObligations);
|
|
319
335
|
this.instanceAiConfig = globalConfig.instanceAi;
|
|
@@ -382,123 +398,69 @@ let InstanceAiService = class InstanceAiService {
|
|
|
382
398
|
if (this.instanceSettings.isLeader)
|
|
383
399
|
this.startCheckpointPruning();
|
|
384
400
|
}
|
|
385
|
-
async
|
|
401
|
+
async createProxyRunConfig(user) {
|
|
402
|
+
if (!this.aiService.isProxyEnabled())
|
|
403
|
+
return {};
|
|
386
404
|
const client = await this.aiService.getClient();
|
|
387
|
-
const
|
|
405
|
+
const proxyBaseUrl = client.getApiProxyBaseUrl();
|
|
406
|
+
const tokenManager = new proxy_token_manager_1.ProxyTokenManager(async () => {
|
|
407
|
+
return await client.getBuilderApiProxyToken({ id: user.id }, { userMessageId: (0, nanoid_1.nanoid)() });
|
|
408
|
+
});
|
|
409
|
+
const featureHeaders = (0, api_types_1.buildProxyHeaders)({
|
|
410
|
+
feature: 'instance-ai',
|
|
411
|
+
n8nVersion: constants_1.N8N_VERSION,
|
|
412
|
+
});
|
|
388
413
|
return {
|
|
389
|
-
|
|
390
|
-
|
|
414
|
+
proxyBaseUrl,
|
|
415
|
+
tokenManager,
|
|
416
|
+
searchProxyConfig: {
|
|
417
|
+
apiUrl: proxyBaseUrl + '/brave-search',
|
|
418
|
+
getAuthHeaders: async () => ({
|
|
419
|
+
...(await tokenManager.getAuthHeaders()),
|
|
420
|
+
...featureHeaders,
|
|
421
|
+
}),
|
|
422
|
+
},
|
|
423
|
+
tracingProxyConfig: {
|
|
424
|
+
apiUrl: proxyBaseUrl + '/langsmith',
|
|
425
|
+
getAuthHeaders: async () => ({
|
|
426
|
+
...(await tokenManager.getAuthHeaders()),
|
|
427
|
+
...featureHeaders,
|
|
428
|
+
}),
|
|
429
|
+
},
|
|
391
430
|
};
|
|
392
431
|
}
|
|
393
432
|
async resolveAgentModelConfig(user) {
|
|
394
|
-
|
|
395
|
-
const client = await this.aiService.getClient();
|
|
396
|
-
const proxyBaseUrl = client.getApiProxyBaseUrl();
|
|
397
|
-
const tokenManager = new proxy_token_manager_1.ProxyTokenManager(async () => {
|
|
398
|
-
return await client.getBuilderApiProxyToken({ id: user.id }, { userMessageId: (0, nanoid_1.nanoid)() });
|
|
399
|
-
});
|
|
400
|
-
return await this.resolveProxyModel(user, proxyBaseUrl, tokenManager);
|
|
401
|
-
}
|
|
402
|
-
const httpProxyModel = await this.resolveHttpProxyModel(user);
|
|
403
|
-
if (httpProxyModel)
|
|
404
|
-
return httpProxyModel;
|
|
405
|
-
return await this.settingsService.resolveModelConfig(user);
|
|
406
|
-
}
|
|
407
|
-
async resolveProxyModel(user, proxyBaseUrl, tokenManager) {
|
|
408
|
-
const modelName = this.settingsService.resolveModelName(user);
|
|
409
|
-
const { createAnthropic } = await Promise.resolve().then(() => __importStar(require('@ai-sdk/anthropic')));
|
|
410
|
-
const provider = createAnthropic({
|
|
411
|
-
baseURL: proxyBaseUrl + '/anthropic/v1',
|
|
412
|
-
apiKey: 'proxy-managed',
|
|
413
|
-
fetch: async (input, init) => {
|
|
414
|
-
const headers = new Headers(init?.headers);
|
|
415
|
-
const auth = await tokenManager.getAuthHeaders();
|
|
416
|
-
for (const [k, v] of Object.entries(auth)) {
|
|
417
|
-
headers.set(k, v);
|
|
418
|
-
}
|
|
419
|
-
for (const [k, v] of Object.entries((0, api_types_1.buildProxyHeaders)({ feature: 'instance-ai', n8nVersion: constants_1.N8N_VERSION }))) {
|
|
420
|
-
headers.set(k, v);
|
|
421
|
-
}
|
|
422
|
-
return await globalThis.fetch(input, { ...init, headers });
|
|
423
|
-
},
|
|
424
|
-
});
|
|
425
|
-
return provider(modelName);
|
|
433
|
+
return await this.modelService.resolveAgentModelConfig(user);
|
|
426
434
|
}
|
|
427
|
-
async
|
|
428
|
-
const proxyFetch = getProxyFetch();
|
|
429
|
-
if (!proxyFetch)
|
|
430
|
-
return undefined;
|
|
431
|
-
const config = await this.settingsService.resolveModelConfig(user);
|
|
432
|
-
const modelId = typeof config === 'string' ? config : 'id' in config ? config.id : null;
|
|
433
|
-
if (!modelId)
|
|
434
|
-
return undefined;
|
|
435
|
-
const [provider, ...rest] = modelId.split('/');
|
|
436
|
-
const modelName = rest.join('/');
|
|
437
|
-
const apiKey = typeof config === 'object' && 'apiKey' in config ? config.apiKey : undefined;
|
|
438
|
-
const baseURL = typeof config === 'object' && 'url' in config ? config.url : undefined;
|
|
439
|
-
if (provider !== 'anthropic')
|
|
440
|
-
return undefined;
|
|
441
|
-
const { createAnthropic } = await Promise.resolve().then(() => __importStar(require('@ai-sdk/anthropic')));
|
|
442
|
-
return createAnthropic({
|
|
443
|
-
apiKey,
|
|
444
|
-
baseURL: baseURL || undefined,
|
|
445
|
-
fetch: proxyFetch,
|
|
446
|
-
})(modelName);
|
|
447
|
-
}
|
|
448
|
-
async countCreditsIfFirst(user, threadId, runId) {
|
|
449
|
-
if (!this.aiService.isProxyEnabled())
|
|
450
|
-
return;
|
|
451
|
-
if (this.creditedThreads.has(threadId))
|
|
452
|
-
return;
|
|
453
|
-
let thread;
|
|
435
|
+
async loadThreadSessionGrants(threadId, userId) {
|
|
454
436
|
try {
|
|
455
|
-
|
|
437
|
+
return await this.threadGrantRepo.findKeys(threadId, userId);
|
|
456
438
|
}
|
|
457
439
|
catch (error) {
|
|
458
|
-
this.logger.warn('Failed to
|
|
440
|
+
this.logger.warn('Failed to load Instance AI session grants', {
|
|
459
441
|
threadId,
|
|
460
|
-
runId,
|
|
461
442
|
error: getErrorMessage(error),
|
|
462
443
|
});
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (!thread)
|
|
466
|
-
return;
|
|
467
|
-
if (thread.metadata?.creditCounted) {
|
|
468
|
-
this.creditedThreads.add(threadId);
|
|
469
|
-
return;
|
|
444
|
+
return new Set();
|
|
470
445
|
}
|
|
446
|
+
}
|
|
447
|
+
async persistThreadSessionGrant(threadId, userId, key) {
|
|
471
448
|
try {
|
|
472
|
-
this.
|
|
473
|
-
const { client, headers: authHeaders } = await this.getProxyAuth(user);
|
|
474
|
-
const info = await client.markBuilderSuccess({ id: user.id }, authHeaders);
|
|
475
|
-
if (info) {
|
|
476
|
-
thread.metadata = { ...thread.metadata, creditCounted: true };
|
|
477
|
-
await this.threadRepo.save(thread);
|
|
478
|
-
this.push.sendToUsers({
|
|
479
|
-
type: 'updateInstanceAiCredits',
|
|
480
|
-
data: { creditsQuota: info.creditsQuota, creditsClaimed: info.creditsClaimed },
|
|
481
|
-
}, [user.id]);
|
|
482
|
-
}
|
|
449
|
+
await this.threadGrantRepo.grant(threadId, userId, key);
|
|
483
450
|
}
|
|
484
451
|
catch (error) {
|
|
485
|
-
this.
|
|
486
|
-
this.logger.warn('Failed to count Instance AI credits', {
|
|
487
|
-
error: getErrorMessage(error),
|
|
452
|
+
this.logger.warn('Failed to persist Instance AI session grant', {
|
|
488
453
|
threadId,
|
|
489
|
-
|
|
454
|
+
key,
|
|
455
|
+
error: getErrorMessage(error),
|
|
490
456
|
});
|
|
491
457
|
}
|
|
492
458
|
}
|
|
493
459
|
isProxyEnabled() {
|
|
494
|
-
return this.
|
|
460
|
+
return this.modelService.isProxyEnabled();
|
|
495
461
|
}
|
|
496
462
|
async getCredits(user) {
|
|
497
|
-
|
|
498
|
-
return { creditsQuota: api_types_1.UNLIMITED_CREDITS, creditsClaimed: 0 };
|
|
499
|
-
}
|
|
500
|
-
const client = await this.aiService.getClient();
|
|
501
|
-
return await client.getBuilderInstanceCredits({ id: user.id });
|
|
463
|
+
return await this.modelService.getCredits(user);
|
|
502
464
|
}
|
|
503
465
|
isEnabled() {
|
|
504
466
|
return this.settingsService.isAgentEnabled() && !!this.instanceAiConfig.model;
|
|
@@ -507,7 +469,31 @@ let InstanceAiService = class InstanceAiService {
|
|
|
507
469
|
return this.runState.hasLiveRun(threadId);
|
|
508
470
|
}
|
|
509
471
|
getThreadStatus(threadId) {
|
|
510
|
-
|
|
472
|
+
const status = this.runState.getThreadStatus(threadId, this.backgroundTasks.getTaskSnapshots(threadId));
|
|
473
|
+
const memoryTasks = this.memoryTaskRegistry.getTasks(threadId);
|
|
474
|
+
return { ...status, memoryTasks };
|
|
475
|
+
}
|
|
476
|
+
memoryTaskObserverFor(threadId) {
|
|
477
|
+
return (event) => {
|
|
478
|
+
this.memoryTaskRegistry.handleEvent(threadId, event);
|
|
479
|
+
const pendingTasks = this.memoryTaskRegistry.getTasks(threadId);
|
|
480
|
+
const logContext = {
|
|
481
|
+
threadId,
|
|
482
|
+
taskId: event.task.id,
|
|
483
|
+
taskKind: event.task.taskKind,
|
|
484
|
+
pendingCount: pendingTasks.length,
|
|
485
|
+
...(event.type === 'skipped' ? { reason: event.reason } : {}),
|
|
486
|
+
...(event.type === 'failed' ? { error: getErrorMessage(event.error) } : {}),
|
|
487
|
+
...(event.type === 'completed' &&
|
|
488
|
+
event.value &&
|
|
489
|
+
typeof event.value === 'object' &&
|
|
490
|
+
'status' in event.value &&
|
|
491
|
+
typeof event.value.status === 'string'
|
|
492
|
+
? { outcome: event.value.status }
|
|
493
|
+
: {}),
|
|
494
|
+
};
|
|
495
|
+
this.logger.info(`Observational memory task ${event.type}`, logContext);
|
|
496
|
+
};
|
|
511
497
|
}
|
|
512
498
|
storeTraceContext(runId, threadId, tracing, messageGroupId) {
|
|
513
499
|
const existing = this.traceContextsByRunId.get(runId);
|
|
@@ -526,6 +512,82 @@ let InstanceAiService = class InstanceAiService {
|
|
|
526
512
|
getTraceContext(runId) {
|
|
527
513
|
return this.traceContextsByRunId.get(runId)?.tracing;
|
|
528
514
|
}
|
|
515
|
+
reportInstanceAiError(error, context) {
|
|
516
|
+
if (typeof error === 'object' && error !== null) {
|
|
517
|
+
if (this.reportedErrors.has(error))
|
|
518
|
+
return;
|
|
519
|
+
this.reportedErrors.add(error);
|
|
520
|
+
}
|
|
521
|
+
const observability = (0, observability_1.buildInstanceAiObservabilityContext)(context);
|
|
522
|
+
this.logger.error(`Instance AI error in ${context.component}`, {
|
|
523
|
+
error,
|
|
524
|
+
component: context.component,
|
|
525
|
+
...observability,
|
|
526
|
+
});
|
|
527
|
+
this.errorReporter.error(error, {
|
|
528
|
+
tags: { component: context.component, ...observability },
|
|
529
|
+
extra: observability,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
async withSetupBoundary(component, context, fn) {
|
|
533
|
+
try {
|
|
534
|
+
return await fn();
|
|
535
|
+
}
|
|
536
|
+
catch (error) {
|
|
537
|
+
this.reportInstanceAiError(error, { component, ...context });
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
isRunDebugEnabled() {
|
|
542
|
+
return this.instanceAiConfig.runDebugEnabled;
|
|
543
|
+
}
|
|
544
|
+
buildOrchestratorAgentStreamOptions(user, threadId, runId, signal) {
|
|
545
|
+
if (this.isRunDebugEnabled()) {
|
|
546
|
+
this.runDebugBuffer.ensure(runId, threadId);
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
maxIterations: instance_ai_1.MAX_STEPS.ORCHESTRATOR,
|
|
550
|
+
abortSignal: signal,
|
|
551
|
+
recoverUsageOnAbort: true,
|
|
552
|
+
persistence: {
|
|
553
|
+
resourceId: user.id,
|
|
554
|
+
threadId,
|
|
555
|
+
},
|
|
556
|
+
providerOptions: {
|
|
557
|
+
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
558
|
+
},
|
|
559
|
+
...(this.isRunDebugEnabled()
|
|
560
|
+
? (0, instance_ai_1.createRunDebugStepHooks)(this.runDebugBuffer, { runId, threadId })
|
|
561
|
+
: {}),
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
buildOrchestratorResumeAgentOptions(user, threadId, runId, agentRunId, toolCallId) {
|
|
565
|
+
if (this.isRunDebugEnabled()) {
|
|
566
|
+
this.runDebugBuffer.ensure(runId, threadId);
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
runId: agentRunId,
|
|
570
|
+
toolCallId,
|
|
571
|
+
recoverUsageOnAbort: true,
|
|
572
|
+
persistence: { resourceId: user.id, threadId },
|
|
573
|
+
...(this.isRunDebugEnabled()
|
|
574
|
+
? (0, instance_ai_1.createRunDebugStepHooks)(this.runDebugBuffer, { runId, threadId })
|
|
575
|
+
: {}),
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
getRunDebug(runId) {
|
|
579
|
+
return this.runDebugBuffer.get(runId);
|
|
580
|
+
}
|
|
581
|
+
listThreadDebugRuns(threadId) {
|
|
582
|
+
return this.runDebugBuffer.listByThread(threadId).map((record) => ({
|
|
583
|
+
runId: record.runId,
|
|
584
|
+
threadId: record.threadId,
|
|
585
|
+
startedAt: record.startedAt,
|
|
586
|
+
stepCount: record.steps.length,
|
|
587
|
+
workflowCodeCount: record.workflowCode.length,
|
|
588
|
+
label: record.label,
|
|
589
|
+
}));
|
|
590
|
+
}
|
|
529
591
|
getTraceContextForContinuation(threadId, messageGroupId) {
|
|
530
592
|
const entries = [...this.traceContextsByRunId.values()].reverse();
|
|
531
593
|
const sameGroup = messageGroupId === undefined
|
|
@@ -818,7 +880,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
818
880
|
userId: user.id,
|
|
819
881
|
message: { id: userMessageId, text: message },
|
|
820
882
|
});
|
|
821
|
-
this.startExecuteRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone
|
|
883
|
+
this.startExecuteRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone);
|
|
822
884
|
return runId;
|
|
823
885
|
}
|
|
824
886
|
getMessageGroupId(threadId) {
|
|
@@ -1051,14 +1113,15 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1051
1113
|
reason: 'thread_cleared',
|
|
1052
1114
|
metadata: { completion_source: 'service_cleanup' },
|
|
1053
1115
|
});
|
|
1054
|
-
this.creditedThreads.delete(threadId);
|
|
1055
1116
|
this.schedulerLocks.delete(threadId);
|
|
1056
1117
|
this.domainAccessTrackersByThread.delete(threadId);
|
|
1118
|
+
this.evalCredentialAllowlists.clearThread(threadId);
|
|
1057
1119
|
this.threadPushRef.delete(threadId);
|
|
1058
1120
|
this.planRequestsByThread.delete(threadId);
|
|
1121
|
+
this.memoryTaskRegistry.clearThread(threadId);
|
|
1059
1122
|
this.deleteTraceContextsForThread(threadId);
|
|
1060
1123
|
await this.sandboxService.destroySandbox(threadId);
|
|
1061
|
-
await this.
|
|
1124
|
+
await this.temporaryWorkflowService.reapForThreadCleanup(threadId);
|
|
1062
1125
|
await this.suspendedThreads.dropPendingConfirmationsForThread(threadId);
|
|
1063
1126
|
this.eventBus.clearThread(threadId);
|
|
1064
1127
|
}
|
|
@@ -1659,7 +1722,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1659
1722
|
});
|
|
1660
1723
|
}
|
|
1661
1724
|
}
|
|
1662
|
-
async createExecutionEnvironment(user, threadId, runId, abortSignal, messageGroupId, pushRef) {
|
|
1725
|
+
async createExecutionEnvironment(user, threadId, runId, abortSignal, messageGroupId, pushRef, proxyRunConfig) {
|
|
1663
1726
|
const memory = this.agentMemory;
|
|
1664
1727
|
const boundProjectId = await memory.getThreadProjectId(threadId);
|
|
1665
1728
|
if (!boundProjectId) {
|
|
@@ -1669,41 +1732,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1669
1732
|
const localGatewayDisabledGlobally = adminSettings.localGatewayDisabled;
|
|
1670
1733
|
const localGatewayDisabledForUser = await this.settingsService.isLocalGatewayDisabledForUser(user.id);
|
|
1671
1734
|
const userGateway = this.gatewayService.findGateway(user.id);
|
|
1672
|
-
|
|
1673
|
-
let tracingProxyConfig;
|
|
1674
|
-
let tokenManager;
|
|
1675
|
-
let proxyBaseUrl;
|
|
1676
|
-
if (this.aiService.isProxyEnabled()) {
|
|
1677
|
-
const client = await this.aiService.getClient();
|
|
1678
|
-
proxyBaseUrl = client.getApiProxyBaseUrl();
|
|
1679
|
-
const manager = new proxy_token_manager_1.ProxyTokenManager(async () => {
|
|
1680
|
-
return await client.getBuilderApiProxyToken({ id: user.id }, { userMessageId: (0, nanoid_1.nanoid)() });
|
|
1681
|
-
});
|
|
1682
|
-
tokenManager = manager;
|
|
1683
|
-
const featureHeaders = (0, api_types_1.buildProxyHeaders)({
|
|
1684
|
-
feature: 'instance-ai',
|
|
1685
|
-
n8nVersion: constants_1.N8N_VERSION,
|
|
1686
|
-
});
|
|
1687
|
-
searchProxyConfig = {
|
|
1688
|
-
apiUrl: proxyBaseUrl + '/brave-search',
|
|
1689
|
-
getAuthHeaders: async () => ({
|
|
1690
|
-
...(await manager.getAuthHeaders()),
|
|
1691
|
-
...featureHeaders,
|
|
1692
|
-
}),
|
|
1693
|
-
};
|
|
1694
|
-
tracingProxyConfig = {
|
|
1695
|
-
apiUrl: proxyBaseUrl + '/langsmith',
|
|
1696
|
-
getAuthHeaders: async () => ({
|
|
1697
|
-
...(await manager.getAuthHeaders()),
|
|
1698
|
-
...featureHeaders,
|
|
1699
|
-
}),
|
|
1700
|
-
};
|
|
1701
|
-
}
|
|
1735
|
+
const { searchProxyConfig, tracingProxyConfig, tokenManager, proxyBaseUrl } = proxyRunConfig ?? (await this.createProxyRunConfig(user));
|
|
1702
1736
|
const context = this.adapterService.createContext(user, {
|
|
1703
1737
|
searchProxyConfig,
|
|
1704
1738
|
pushRef,
|
|
1705
1739
|
threadId,
|
|
1706
1740
|
projectId: boundProjectId,
|
|
1741
|
+
credentialIdAllowlist: this.evalCredentialAllowlists.get(threadId),
|
|
1707
1742
|
});
|
|
1708
1743
|
if (!localGatewayDisabledForUser && userGateway?.isConnected) {
|
|
1709
1744
|
context.localMcpServer = userGateway;
|
|
@@ -1720,6 +1755,18 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1720
1755
|
}
|
|
1721
1756
|
context.domainAccessTracker = domainTracker;
|
|
1722
1757
|
context.runId = runId;
|
|
1758
|
+
const sessionGrants = await this.loadThreadSessionGrants(threadId, user.id);
|
|
1759
|
+
context.sessionApprovedToolKeys = sessionGrants;
|
|
1760
|
+
context.grantSessionToolApproval = async (key) => {
|
|
1761
|
+
await this.persistThreadSessionGrant(threadId, user.id, key);
|
|
1762
|
+
sessionGrants.add(key);
|
|
1763
|
+
};
|
|
1764
|
+
if (this.isRunDebugEnabled()) {
|
|
1765
|
+
context.recordWorkflowCodeSnapshot = (snapshot) => {
|
|
1766
|
+
this.runDebugBuffer.ensure(runId, threadId);
|
|
1767
|
+
this.runDebugBuffer.recordWorkflowCode(runId, snapshot);
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1723
1770
|
if (localGatewayDisabledGlobally) {
|
|
1724
1771
|
context.localGatewayStatus = { status: 'disabledGlobally' };
|
|
1725
1772
|
}
|
|
@@ -1738,8 +1785,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1738
1785
|
};
|
|
1739
1786
|
}
|
|
1740
1787
|
const modelId = proxyBaseUrl && tokenManager
|
|
1741
|
-
? await this.resolveProxyModel(user, proxyBaseUrl, tokenManager)
|
|
1742
|
-
: await this.resolveAgentModelConfig(user);
|
|
1788
|
+
? await this.modelService.resolveProxyModel(user, proxyBaseUrl, tokenManager)
|
|
1789
|
+
: await this.modelService.resolveAgentModelConfig(user);
|
|
1743
1790
|
const taskStorage = new instance_ai_1.ThreadTaskStorage(memory);
|
|
1744
1791
|
const iterationLog = this.dbIterationLogStorage;
|
|
1745
1792
|
const snapshotStorage = this.dbSnapshotStorage;
|
|
@@ -1751,14 +1798,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1751
1798
|
if (nodeDefDirs.length > 0) {
|
|
1752
1799
|
(0, workflow_sdk_1.setSchemaBaseDirs)(nodeDefDirs);
|
|
1753
1800
|
}
|
|
1754
|
-
const domainTools = (0, instance_ai_1.createAllTools)(context);
|
|
1755
1801
|
const baseRuntimeSkills = (0, instance_ai_1.loadInstanceAiRuntimeSkillSource)();
|
|
1756
1802
|
let runtimeSkills = baseRuntimeSkills;
|
|
1757
1803
|
let runtimeWorkspace;
|
|
1758
1804
|
let workspaceRoot;
|
|
1759
1805
|
const sandboxStatus = this.settingsService.getSandboxStatus();
|
|
1760
1806
|
if (sandboxStatus.workflowBuilderAvailable) {
|
|
1761
|
-
const sandboxConfig = await this.sandboxService.resolveSandboxConfig(user);
|
|
1807
|
+
const sandboxConfig = await this.withSetupBoundary('instance-ai-sandbox-setup', { threadId, runId, userId: user.id, messageGroupId }, async () => await this.sandboxService.resolveSandboxConfig(user));
|
|
1762
1808
|
if (sandboxConfig.enabled) {
|
|
1763
1809
|
workspaceRoot = (0, instance_ai_1.getPromptWorkspaceRoot)(sandboxConfig.provider);
|
|
1764
1810
|
let sandboxEntryPromise;
|
|
@@ -1795,6 +1841,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1795
1841
|
});
|
|
1796
1842
|
}
|
|
1797
1843
|
}
|
|
1844
|
+
context.workspace = runtimeWorkspace;
|
|
1845
|
+
context.threadId = threadId;
|
|
1846
|
+
context.threadMemory = memory;
|
|
1847
|
+
context.trackTelemetry = (eventName, properties) => {
|
|
1848
|
+
this.telemetry.track(eventName, properties);
|
|
1849
|
+
};
|
|
1850
|
+
const domainTools = (0, instance_ai_1.createAllTools)(context);
|
|
1798
1851
|
const orchestrationContext = {
|
|
1799
1852
|
threadId,
|
|
1800
1853
|
runId,
|
|
@@ -2273,6 +2326,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2273
2326
|
}
|
|
2274
2327
|
async executeRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone, isReplanFollowUp = false, checkpoint, resumeReason, plannedBuild) {
|
|
2275
2328
|
const userMessagePersistence = this.userMessagePersistenceByRun.get(runId)?.message;
|
|
2329
|
+
const fileAttachments = (attachments ?? []).filter((attachment) => attachment.type === 'file');
|
|
2330
|
+
const workflowAttachments = (attachments ?? []).filter((attachment) => attachment.type === 'workflow');
|
|
2276
2331
|
const signal = abortController.signal;
|
|
2277
2332
|
let tracing;
|
|
2278
2333
|
let messageTraceFinalization;
|
|
@@ -2281,12 +2336,61 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2281
2336
|
let messageId = '';
|
|
2282
2337
|
try {
|
|
2283
2338
|
messageId = (0, nanoid_1.nanoid)();
|
|
2339
|
+
const traceInput = {
|
|
2340
|
+
message,
|
|
2341
|
+
...(fileAttachments.length
|
|
2342
|
+
? {
|
|
2343
|
+
attachments: fileAttachments.map((attachment) => ({
|
|
2344
|
+
mimeType: attachment.mimeType,
|
|
2345
|
+
size: attachment.data.length,
|
|
2346
|
+
})),
|
|
2347
|
+
}
|
|
2348
|
+
: {}),
|
|
2349
|
+
...(messageGroupId ? { messageGroupId } : {}),
|
|
2350
|
+
};
|
|
2351
|
+
const proxyRunConfig = await this.createProxyRunConfig(user);
|
|
2352
|
+
if (resumeReason) {
|
|
2353
|
+
tracing = await this.createOrchestratorResumeTraceContext({
|
|
2354
|
+
threadId,
|
|
2355
|
+
messageId,
|
|
2356
|
+
messageGroupId,
|
|
2357
|
+
runId,
|
|
2358
|
+
userId: user.id,
|
|
2359
|
+
input: traceInput,
|
|
2360
|
+
resumeReason,
|
|
2361
|
+
metadata: {
|
|
2362
|
+
...(checkpoint?.isCheckpointFollowUp
|
|
2363
|
+
? { checkpoint_task_id: checkpoint.checkpointTaskId }
|
|
2364
|
+
: {}),
|
|
2365
|
+
...(plannedBuild?.isPlannedBuildFollowUp
|
|
2366
|
+
? { build_task_id: plannedBuild.buildTaskId }
|
|
2367
|
+
: {}),
|
|
2368
|
+
},
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
else {
|
|
2372
|
+
tracing = await (0, instance_ai_1.createInstanceAiTraceContext)({
|
|
2373
|
+
threadId,
|
|
2374
|
+
messageId,
|
|
2375
|
+
messageGroupId,
|
|
2376
|
+
runId,
|
|
2377
|
+
userId: user.id,
|
|
2378
|
+
input: traceInput,
|
|
2379
|
+
proxyConfig: proxyRunConfig.tracingProxyConfig,
|
|
2380
|
+
n8nVersion: constants_1.N8N_VERSION,
|
|
2381
|
+
workflowSdkVersion: constants_1.WORKFLOW_SDK_VERSION,
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
if (this.isRunDebugEnabled()) {
|
|
2385
|
+
this.runDebugBuffer.ensure(runId, threadId, (0, instance_ai_1.buildRunDebugLabel)({ message, resumeReason }));
|
|
2386
|
+
}
|
|
2387
|
+
const traceId = tracing?.rootRun.otelTraceId;
|
|
2284
2388
|
this.eventBus.publish(threadId, {
|
|
2285
2389
|
type: 'run-start',
|
|
2286
2390
|
runId,
|
|
2287
2391
|
agentId: ORCHESTRATOR_AGENT_ID,
|
|
2288
2392
|
userId: user.id,
|
|
2289
|
-
payload: { messageId, messageGroupId },
|
|
2393
|
+
payload: { messageId, messageGroupId, ...(traceId ? { traceId } : {}) },
|
|
2290
2394
|
});
|
|
2291
2395
|
if (signal.aborted) {
|
|
2292
2396
|
this.evaluateTerminalResponse(threadId, runId, 'cancelled', {
|
|
@@ -2302,10 +2406,20 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2302
2406
|
return;
|
|
2303
2407
|
}
|
|
2304
2408
|
const staticMcpServers = this.parseMcpServers(this.instanceAiConfig.mcpServers);
|
|
2305
|
-
const registryMcpServers =
|
|
2409
|
+
const registryMcpServers = this.settingsService.isMcpAccessEnabled()
|
|
2410
|
+
? await this.withSetupBoundary('instance-ai-mcp-setup', {
|
|
2411
|
+
threadId,
|
|
2412
|
+
runId,
|
|
2413
|
+
tracing,
|
|
2414
|
+
agentId: ORCHESTRATOR_AGENT_ID,
|
|
2415
|
+
userId: user.id,
|
|
2416
|
+
messageGroupId,
|
|
2417
|
+
messageId,
|
|
2418
|
+
}, async () => await this.mcpRegistryService.getRegistryMcpServers(user))
|
|
2419
|
+
: [];
|
|
2306
2420
|
const mcpServers = [...staticMcpServers, ...registryMcpServers];
|
|
2307
2421
|
const executionPushRef = this.threadPushRef.get(threadId);
|
|
2308
|
-
const environment = await this.createExecutionEnvironment(user, threadId, runId, signal, messageGroupId, executionPushRef);
|
|
2422
|
+
const environment = await this.createExecutionEnvironment(user, threadId, runId, signal, messageGroupId, executionPushRef, proxyRunConfig);
|
|
2309
2423
|
activeSnapshotStorage = environment.snapshotStorage;
|
|
2310
2424
|
const { context, memory, taskStorage, snapshotStorage, workflowTasks, plannedTaskService, modelId, orchestrationContext, } = environment;
|
|
2311
2425
|
aiCreatedWorkflowIds = context.aiCreatedWorkflowIds ??= new Set();
|
|
@@ -2354,54 +2468,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2354
2468
|
workflowTaskService: workflowTasks,
|
|
2355
2469
|
};
|
|
2356
2470
|
}
|
|
2357
|
-
if (
|
|
2358
|
-
context.currentUserAttachments =
|
|
2471
|
+
if (fileAttachments.length > 0) {
|
|
2472
|
+
context.currentUserAttachments = fileAttachments;
|
|
2359
2473
|
}
|
|
2360
2474
|
const memoryConfig = this.createAgentMemoryOptions();
|
|
2361
|
-
const traceInput = {
|
|
2362
|
-
message,
|
|
2363
|
-
...(attachments?.length
|
|
2364
|
-
? {
|
|
2365
|
-
attachments: attachments.map((attachment) => ({
|
|
2366
|
-
mimeType: attachment.mimeType,
|
|
2367
|
-
size: attachment.data.length,
|
|
2368
|
-
})),
|
|
2369
|
-
}
|
|
2370
|
-
: {}),
|
|
2371
|
-
...(messageGroupId ? { messageGroupId } : {}),
|
|
2372
|
-
};
|
|
2373
|
-
tracing = resumeReason
|
|
2374
|
-
? await this.createOrchestratorResumeTraceContext({
|
|
2375
|
-
threadId,
|
|
2376
|
-
messageId,
|
|
2377
|
-
messageGroupId,
|
|
2378
|
-
runId,
|
|
2379
|
-
userId: user.id,
|
|
2380
|
-
modelId,
|
|
2381
|
-
input: traceInput,
|
|
2382
|
-
proxyConfig: orchestrationContext.tracingProxyConfig,
|
|
2383
|
-
resumeReason,
|
|
2384
|
-
metadata: {
|
|
2385
|
-
...(checkpoint?.isCheckpointFollowUp
|
|
2386
|
-
? { checkpoint_task_id: checkpoint.checkpointTaskId }
|
|
2387
|
-
: {}),
|
|
2388
|
-
...(plannedBuild?.isPlannedBuildFollowUp
|
|
2389
|
-
? { build_task_id: plannedBuild.buildTaskId }
|
|
2390
|
-
: {}),
|
|
2391
|
-
},
|
|
2392
|
-
})
|
|
2393
|
-
: await (0, instance_ai_1.createInstanceAiTraceContext)({
|
|
2394
|
-
threadId,
|
|
2395
|
-
messageId,
|
|
2396
|
-
messageGroupId,
|
|
2397
|
-
runId,
|
|
2398
|
-
userId: user.id,
|
|
2399
|
-
modelId,
|
|
2400
|
-
input: traceInput,
|
|
2401
|
-
proxyConfig: orchestrationContext.tracingProxyConfig,
|
|
2402
|
-
n8nVersion: constants_1.N8N_VERSION,
|
|
2403
|
-
workflowSdkVersion: constants_1.WORKFLOW_SDK_VERSION,
|
|
2404
|
-
});
|
|
2405
2475
|
if (!tracing && process.env.E2E_TESTS === 'true') {
|
|
2406
2476
|
const { createTraceReplayOnlyContext } = await Promise.resolve().then(() => __importStar(require('@n8n/instance-ai')));
|
|
2407
2477
|
tracing = createTraceReplayOnlyContext();
|
|
@@ -2416,9 +2486,15 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2416
2486
|
}
|
|
2417
2487
|
const thread = await memory.getThread(threadId);
|
|
2418
2488
|
if (thread && !thread.title) {
|
|
2489
|
+
const handoffTitle = workflowAttachments.find((attachment) => attachment.name)?.name;
|
|
2419
2490
|
await (0, instance_ai_1.patchThread)(memory, {
|
|
2420
2491
|
threadId,
|
|
2421
|
-
update: (
|
|
2492
|
+
update: ({ metadata }) => handoffTitle
|
|
2493
|
+
? {
|
|
2494
|
+
title: (0, instance_ai_1.truncateToTitle)(handoffTitle),
|
|
2495
|
+
metadata: { ...metadata, titleRefined: true },
|
|
2496
|
+
}
|
|
2497
|
+
: { title: (0, instance_ai_1.truncateToTitle)(message) },
|
|
2422
2498
|
});
|
|
2423
2499
|
}
|
|
2424
2500
|
const existingTasks = await taskStorage.get(threadId);
|
|
@@ -2431,12 +2507,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2431
2507
|
});
|
|
2432
2508
|
}
|
|
2433
2509
|
const enrichedMessage = await this.buildMessageWithRunningTasks(threadId, message);
|
|
2510
|
+
const contextResourcesBlock = buildContextResourcesBlock(workflowAttachments);
|
|
2434
2511
|
let nonStructuredAttachments = [];
|
|
2435
2512
|
let attachmentManifest = '';
|
|
2436
2513
|
let hasParseableAttachment = false;
|
|
2437
|
-
if (
|
|
2438
|
-
const classifiedAttachments = (0, instance_ai_1.classifyAttachments)(
|
|
2439
|
-
nonStructuredAttachments =
|
|
2514
|
+
if (fileAttachments.length > 0) {
|
|
2515
|
+
const classifiedAttachments = (0, instance_ai_1.classifyAttachments)(fileAttachments);
|
|
2516
|
+
nonStructuredAttachments = fileAttachments.filter((attachment) => !(0, instance_ai_1.isParseableAttachment)(attachment));
|
|
2440
2517
|
hasParseableAttachment = classifiedAttachments.some((attachment) => attachment.parseable);
|
|
2441
2518
|
attachmentManifest = (0, instance_ai_1.buildAttachmentManifest)(classifiedAttachments);
|
|
2442
2519
|
}
|
|
@@ -2445,7 +2522,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2445
2522
|
: attachmentManifest
|
|
2446
2523
|
? `${enrichedMessage}\n\n${attachmentManifest}`
|
|
2447
2524
|
: enrichedMessage;
|
|
2448
|
-
const
|
|
2525
|
+
const messageWithContext = [contextResourcesBlock, messageBody].filter(Boolean).join('\n\n');
|
|
2526
|
+
const fullMessage = (0, internal_messages_1.withCurrentDateTime)(messageWithContext, (0, instance_ai_1.getDateTimeSection)(timeZone ?? this.defaultTimeZone));
|
|
2449
2527
|
const promptBuildRun = tracing
|
|
2450
2528
|
? await tracing.startChildRun(tracing.messageRun, {
|
|
2451
2529
|
name: 'prepare: prompt',
|
|
@@ -2527,20 +2605,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2527
2605
|
memoryConfig,
|
|
2528
2606
|
memory,
|
|
2529
2607
|
checkpointStore: this.checkpointStore,
|
|
2608
|
+
onMemoryTaskEvent: this.memoryTaskObserverFor(threadId),
|
|
2609
|
+
thinkingEnabled: this.instanceAiConfig.thinkingEnabled,
|
|
2530
2610
|
});
|
|
2611
|
+
const streamOptions = this.buildOrchestratorAgentStreamOptions(user, threadId, runId, signal);
|
|
2531
2612
|
const result = tracing
|
|
2532
2613
|
? await tracing.withActiveSpan(tracing.actorRun, async () => {
|
|
2533
|
-
return await (0, instance_ai_1.streamAgentRun)(agent, streamInput, {
|
|
2534
|
-
maxIterations: instance_ai_1.MAX_STEPS.ORCHESTRATOR,
|
|
2535
|
-
abortSignal: signal,
|
|
2536
|
-
persistence: {
|
|
2537
|
-
resourceId: user.id,
|
|
2538
|
-
threadId,
|
|
2539
|
-
},
|
|
2540
|
-
providerOptions: {
|
|
2541
|
-
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
2542
|
-
},
|
|
2543
|
-
}, {
|
|
2614
|
+
return await (0, instance_ai_1.streamAgentRun)(agent, streamInput, streamOptions, {
|
|
2544
2615
|
threadId,
|
|
2545
2616
|
runId,
|
|
2546
2617
|
agentId: ORCHESTRATOR_AGENT_ID,
|
|
@@ -2551,17 +2622,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2551
2622
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
2552
2623
|
});
|
|
2553
2624
|
})
|
|
2554
|
-
: await (0, instance_ai_1.streamAgentRun)(agent, streamInput, {
|
|
2555
|
-
maxIterations: instance_ai_1.MAX_STEPS.ORCHESTRATOR,
|
|
2556
|
-
abortSignal: signal,
|
|
2557
|
-
persistence: {
|
|
2558
|
-
resourceId: user.id,
|
|
2559
|
-
threadId,
|
|
2560
|
-
},
|
|
2561
|
-
providerOptions: {
|
|
2562
|
-
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
2563
|
-
},
|
|
2564
|
-
}, {
|
|
2625
|
+
: await (0, instance_ai_1.streamAgentRun)(agent, streamInput, streamOptions, {
|
|
2565
2626
|
threadId,
|
|
2566
2627
|
runId,
|
|
2567
2628
|
agentId: ORCHESTRATOR_AGENT_ID,
|
|
@@ -2671,6 +2732,18 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2671
2732
|
return;
|
|
2672
2733
|
}
|
|
2673
2734
|
const outputText = await (result.text ?? Promise.resolve(''));
|
|
2735
|
+
if (result.status === 'errored') {
|
|
2736
|
+
this.reportInstanceAiError(result.error ?? new Error('Instance AI stream errored'), {
|
|
2737
|
+
component: 'instance-ai-stream',
|
|
2738
|
+
threadId,
|
|
2739
|
+
runId,
|
|
2740
|
+
tracing,
|
|
2741
|
+
agentId: ORCHESTRATOR_AGENT_ID,
|
|
2742
|
+
userId: user.id,
|
|
2743
|
+
messageGroupId,
|
|
2744
|
+
messageId,
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2674
2747
|
this.evaluateTerminalResponse(threadId, runId, result.status, {
|
|
2675
2748
|
messageGroupId,
|
|
2676
2749
|
correlationId: messageId,
|
|
@@ -2690,14 +2763,16 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2690
2763
|
modelId,
|
|
2691
2764
|
metadata: this.buildMessageTraceMetadata(threadId, runId, { status: finalStatus }),
|
|
2692
2765
|
};
|
|
2693
|
-
const archivedWorkflowIds = await this.
|
|
2766
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(threadId, user, aiCreatedWorkflowIds, this.backgroundTasks.getRunningTasks(threadId).length);
|
|
2694
2767
|
await this.finalizeRun(threadId, runId, result.status, snapshotStorage, {
|
|
2695
2768
|
userId: user.id,
|
|
2696
2769
|
modelId,
|
|
2697
2770
|
archivedWorkflowIds,
|
|
2771
|
+
workSummary: result.workSummary,
|
|
2772
|
+
usage: result.usage,
|
|
2698
2773
|
});
|
|
2774
|
+
await this.creditService.claimRunUsage(user, threadId, result.agentRunId || runId, result.usage?.usage ?? [], result.status);
|
|
2699
2775
|
if (result.status === 'completed') {
|
|
2700
|
-
await this.countCreditsIfFirst(user, threadId, runId);
|
|
2701
2776
|
this.telemetry.track('Builder sent message', {
|
|
2702
2777
|
thread_id: threadId,
|
|
2703
2778
|
message: outputText,
|
|
@@ -2736,7 +2811,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2736
2811
|
runTimeout,
|
|
2737
2812
|
}),
|
|
2738
2813
|
};
|
|
2739
|
-
const archivedWorkflowIds = await this.
|
|
2814
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(threadId, user, aiCreatedWorkflowIds, this.backgroundTasks.getRunningTasks(threadId).length);
|
|
2740
2815
|
this.publishRunFinish(threadId, runId, 'cancelled', cancellationReason, archivedWorkflowIds);
|
|
2741
2816
|
if (activeSnapshotStorage) {
|
|
2742
2817
|
await this.saveAgentTreeSnapshot(threadId, runId, activeSnapshotStorage);
|
|
@@ -2745,15 +2820,20 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2745
2820
|
}
|
|
2746
2821
|
const errorMessage = getErrorMessage(error);
|
|
2747
2822
|
const userFacingErrorMessage = getUserFacingErrorMessage(error);
|
|
2748
|
-
|
|
2749
|
-
error: errorMessage,
|
|
2823
|
+
const errCtx = {
|
|
2750
2824
|
threadId,
|
|
2751
2825
|
runId,
|
|
2826
|
+
tracing,
|
|
2827
|
+
agentId: ORCHESTRATOR_AGENT_ID,
|
|
2828
|
+
userId: user.id,
|
|
2829
|
+
messageGroupId,
|
|
2830
|
+
messageId,
|
|
2831
|
+
};
|
|
2832
|
+
this.logger.error(`Instance AI run error: ${errorMessage}`, {
|
|
2833
|
+
error: errorMessage,
|
|
2834
|
+
...(0, observability_1.buildInstanceAiObservabilityContext)(errCtx),
|
|
2752
2835
|
});
|
|
2753
|
-
this.
|
|
2754
|
-
tags: { component: 'instance-ai-run' },
|
|
2755
|
-
extra: { threadId, runId },
|
|
2756
|
-
});
|
|
2836
|
+
this.reportInstanceAiError(error, { component: 'instance-ai-run', ...errCtx });
|
|
2757
2837
|
this.evaluateTerminalResponse(threadId, runId, 'errored', {
|
|
2758
2838
|
messageGroupId,
|
|
2759
2839
|
correlationId: messageId,
|
|
@@ -2768,7 +2848,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2768
2848
|
reason: errorMessage,
|
|
2769
2849
|
metadata: this.buildMessageTraceMetadata(threadId, runId, { status: 'error' }),
|
|
2770
2850
|
};
|
|
2771
|
-
const archivedWorkflowIds = await this.
|
|
2851
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(threadId, user, aiCreatedWorkflowIds, this.backgroundTasks.getRunningTasks(threadId).length);
|
|
2772
2852
|
this.eventBus.publish(threadId, {
|
|
2773
2853
|
type: 'run-finish',
|
|
2774
2854
|
runId,
|
|
@@ -3015,6 +3095,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3015
3095
|
memoryConfig: this.createAgentMemoryOptions(),
|
|
3016
3096
|
memory: environment.memory,
|
|
3017
3097
|
checkpointStore: this.checkpointStore,
|
|
3098
|
+
onMemoryTaskEvent: this.memoryTaskObserverFor(orphan.threadId),
|
|
3099
|
+
thinkingEnabled: this.instanceAiConfig.thinkingEnabled,
|
|
3018
3100
|
});
|
|
3019
3101
|
}
|
|
3020
3102
|
catch (error) {
|
|
@@ -3095,6 +3177,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3095
3177
|
...(data.testTriggerNode ? { testTriggerNode: data.testTriggerNode } : {}),
|
|
3096
3178
|
...(data.answers ? { answers: data.answers } : {}),
|
|
3097
3179
|
...(data.resourceDecision ? { resourceDecision: data.resourceDecision } : {}),
|
|
3180
|
+
...(data.scope ? { scope: data.scope } : {}),
|
|
3098
3181
|
};
|
|
3099
3182
|
const resumeTracing = await this.createOrchestratorResumeTraceContext({
|
|
3100
3183
|
baseTracing: tracing,
|
|
@@ -3158,13 +3241,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3158
3241
|
});
|
|
3159
3242
|
}
|
|
3160
3243
|
}
|
|
3244
|
+
const resumeOptions = this.buildOrchestratorResumeAgentOptions(opts.user, opts.threadId, opts.runId, opts.agentRunId, opts.toolCallId);
|
|
3161
3245
|
const result = opts.tracing
|
|
3162
3246
|
? await opts.tracing.withActiveSpan(opts.tracing.actorRun, async () => {
|
|
3163
|
-
return await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, {
|
|
3164
|
-
runId: opts.agentRunId,
|
|
3165
|
-
toolCallId: opts.toolCallId,
|
|
3166
|
-
persistence: { resourceId: opts.user.id, threadId: opts.threadId },
|
|
3167
|
-
}, {
|
|
3247
|
+
return await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, resumeOptions, {
|
|
3168
3248
|
threadId: opts.threadId,
|
|
3169
3249
|
runId: opts.runId,
|
|
3170
3250
|
agentId: ORCHESTRATOR_AGENT_ID,
|
|
@@ -3176,11 +3256,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3176
3256
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
3177
3257
|
});
|
|
3178
3258
|
})
|
|
3179
|
-
: await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, {
|
|
3180
|
-
runId: opts.agentRunId,
|
|
3181
|
-
toolCallId: opts.toolCallId,
|
|
3182
|
-
persistence: { resourceId: opts.user.id, threadId: opts.threadId },
|
|
3183
|
-
}, {
|
|
3259
|
+
: await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, resumeOptions, {
|
|
3184
3260
|
threadId: opts.threadId,
|
|
3185
3261
|
runId: opts.runId,
|
|
3186
3262
|
agentId: ORCHESTRATOR_AGENT_ID,
|
|
@@ -3291,6 +3367,17 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3291
3367
|
}
|
|
3292
3368
|
const outputText = await (result.text ?? Promise.resolve(''));
|
|
3293
3369
|
const messageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
3370
|
+
if (result.status === 'errored') {
|
|
3371
|
+
this.reportInstanceAiError(result.error ?? new Error('Instance AI resumed stream errored'), {
|
|
3372
|
+
component: 'instance-ai-stream',
|
|
3373
|
+
threadId: opts.threadId,
|
|
3374
|
+
runId: opts.runId,
|
|
3375
|
+
tracing: opts.tracing,
|
|
3376
|
+
agentId: ORCHESTRATOR_AGENT_ID,
|
|
3377
|
+
userId: opts.user.id,
|
|
3378
|
+
messageGroupId,
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3294
3381
|
this.evaluateTerminalResponse(opts.threadId, opts.runId, result.status, {
|
|
3295
3382
|
messageGroupId,
|
|
3296
3383
|
workSummary: result.workSummary,
|
|
@@ -3309,12 +3396,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3309
3396
|
status: finalStatus,
|
|
3310
3397
|
}),
|
|
3311
3398
|
};
|
|
3312
|
-
const archivedWorkflowIds = await this.
|
|
3399
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(opts.threadId, opts.user, undefined, this.backgroundTasks.getRunningTasks(opts.threadId).length);
|
|
3313
3400
|
await this.finalizeRun(opts.threadId, opts.runId, result.status, opts.snapshotStorage, {
|
|
3314
3401
|
archivedWorkflowIds,
|
|
3402
|
+
workSummary: result.workSummary,
|
|
3403
|
+
usage: result.usage,
|
|
3315
3404
|
});
|
|
3405
|
+
await this.creditService.claimRunUsage(opts.user, opts.threadId, result.agentRunId || opts.runId, result.usage?.usage ?? [], result.status);
|
|
3316
3406
|
if (result.status === 'completed') {
|
|
3317
|
-
await this.countCreditsIfFirst(opts.user, opts.threadId, opts.runId);
|
|
3318
3407
|
this.telemetry.track('Builder sent message', {
|
|
3319
3408
|
thread_id: opts.threadId,
|
|
3320
3409
|
message: outputText,
|
|
@@ -3353,23 +3442,27 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3353
3442
|
runTimeout,
|
|
3354
3443
|
}),
|
|
3355
3444
|
};
|
|
3356
|
-
const archivedWorkflowIds = await this.
|
|
3445
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(opts.threadId, opts.user, undefined, this.backgroundTasks.getRunningTasks(opts.threadId).length);
|
|
3357
3446
|
this.publishRunFinish(opts.threadId, opts.runId, 'cancelled', cancellationReason, archivedWorkflowIds);
|
|
3358
3447
|
await this.saveAgentTreeSnapshot(opts.threadId, opts.runId, opts.snapshotStorage);
|
|
3359
3448
|
return;
|
|
3360
3449
|
}
|
|
3361
3450
|
const errorMessage = getErrorMessage(error);
|
|
3362
3451
|
const userFacingErrorMessage = getUserFacingErrorMessage(error);
|
|
3363
|
-
this.
|
|
3364
|
-
|
|
3452
|
+
const messageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
3453
|
+
const errCtx = {
|
|
3365
3454
|
threadId: opts.threadId,
|
|
3366
3455
|
runId: opts.runId,
|
|
3456
|
+
tracing: opts.tracing,
|
|
3457
|
+
agentId: ORCHESTRATOR_AGENT_ID,
|
|
3458
|
+
userId: opts.user.id,
|
|
3459
|
+
messageGroupId,
|
|
3460
|
+
};
|
|
3461
|
+
this.logger.error(`Instance AI resumed run error: ${errorMessage}`, {
|
|
3462
|
+
error: errorMessage,
|
|
3463
|
+
...(0, observability_1.buildInstanceAiObservabilityContext)(errCtx),
|
|
3367
3464
|
});
|
|
3368
|
-
this.
|
|
3369
|
-
tags: { component: 'instance-ai-run' },
|
|
3370
|
-
extra: { threadId: opts.threadId, runId: opts.runId },
|
|
3371
|
-
});
|
|
3372
|
-
const messageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
3465
|
+
this.reportInstanceAiError(error, { component: 'instance-ai-run', ...errCtx });
|
|
3373
3466
|
this.evaluateTerminalResponse(opts.threadId, opts.runId, 'errored', {
|
|
3374
3467
|
messageGroupId,
|
|
3375
3468
|
errorMessage: userFacingErrorMessage,
|
|
@@ -3385,7 +3478,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3385
3478
|
status: 'error',
|
|
3386
3479
|
}),
|
|
3387
3480
|
};
|
|
3388
|
-
const archivedWorkflowIds = await this.
|
|
3481
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(opts.threadId, opts.user, undefined, this.backgroundTasks.getRunningTasks(opts.threadId).length);
|
|
3389
3482
|
this.eventBus.publish(opts.threadId, {
|
|
3390
3483
|
type: 'run-finish',
|
|
3391
3484
|
runId: opts.runId,
|
|
@@ -3477,6 +3570,16 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3477
3570
|
},
|
|
3478
3571
|
onFailed: async (task) => {
|
|
3479
3572
|
await this.finalizeBackgroundTaskTracing(task, 'failed');
|
|
3573
|
+
this.reportInstanceAiError(new Error(task.error ?? 'Instance AI background task failed'), {
|
|
3574
|
+
component: 'instance-ai-background-task',
|
|
3575
|
+
threadId: opts.threadId,
|
|
3576
|
+
runId,
|
|
3577
|
+
tracing: task.traceContext,
|
|
3578
|
+
agentId: opts.agentId,
|
|
3579
|
+
messageGroupId: task.messageGroupId,
|
|
3580
|
+
taskId: task.taskId,
|
|
3581
|
+
role: task.role,
|
|
3582
|
+
});
|
|
3480
3583
|
this.eventBus.publish(opts.threadId, {
|
|
3481
3584
|
type: 'agent-completed',
|
|
3482
3585
|
runId,
|
|
@@ -3518,6 +3621,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3518
3621
|
});
|
|
3519
3622
|
return;
|
|
3520
3623
|
}
|
|
3624
|
+
if (task.timeoutReason) {
|
|
3625
|
+
this.logger.debug('Skipping background auto-follow-up after task timeout', {
|
|
3626
|
+
threadId: opts.threadId,
|
|
3627
|
+
taskId: task.taskId,
|
|
3628
|
+
timeoutReason: task.timeoutReason,
|
|
3629
|
+
});
|
|
3630
|
+
return;
|
|
3631
|
+
}
|
|
3521
3632
|
const user = this.runState.getThreadUser(opts.threadId);
|
|
3522
3633
|
if (user) {
|
|
3523
3634
|
const verificationFollowUpStarted = await this.maybeStartWorkflowVerificationFollowUp(user, task);
|
|
@@ -3637,52 +3748,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3637
3748
|
num_steps: numSteps,
|
|
3638
3749
|
});
|
|
3639
3750
|
}
|
|
3640
|
-
async reapAiTemporaryFromRun(threadId, user, createdWorkflowIds) {
|
|
3641
|
-
const runningTaskCount = this.backgroundTasks.getRunningTasks(threadId).length;
|
|
3642
|
-
if (runningTaskCount > 0) {
|
|
3643
|
-
this.logger.debug('Deferring AI-builder temporary workflow cleanup until tasks settle', {
|
|
3644
|
-
threadId,
|
|
3645
|
-
runningTaskCount,
|
|
3646
|
-
});
|
|
3647
|
-
return [];
|
|
3648
|
-
}
|
|
3649
|
-
let markedWorkflows = [];
|
|
3650
|
-
try {
|
|
3651
|
-
markedWorkflows = await this.aiBuilderTemporaryWorkflowRepository.findByThread(threadId);
|
|
3652
|
-
}
|
|
3653
|
-
catch (error) {
|
|
3654
|
-
this.logger.warn('Failed to inspect AI-builder temporary workflows during run finish', {
|
|
3655
|
-
threadId,
|
|
3656
|
-
error: getErrorMessage(error),
|
|
3657
|
-
});
|
|
3658
|
-
}
|
|
3659
|
-
const workflowIds = new Set([
|
|
3660
|
-
...markedWorkflows.map(({ workflowId }) => workflowId),
|
|
3661
|
-
...(createdWorkflowIds ?? []),
|
|
3662
|
-
]);
|
|
3663
|
-
if (workflowIds.size === 0)
|
|
3664
|
-
return [];
|
|
3665
|
-
return await this.archiveAiTemporaryWorkflows(threadId, user, workflowIds);
|
|
3666
|
-
}
|
|
3667
|
-
async archiveAiTemporaryWorkflows(threadId, user, workflowIds) {
|
|
3668
|
-
const adapter = this.adapterService.createContext(user, { threadId });
|
|
3669
|
-
const archived = [];
|
|
3670
|
-
for (const workflowId of workflowIds) {
|
|
3671
|
-
try {
|
|
3672
|
-
const didArchive = await adapter.workflowService.archiveIfAiTemporary(workflowId);
|
|
3673
|
-
if (didArchive)
|
|
3674
|
-
archived.push(workflowId);
|
|
3675
|
-
}
|
|
3676
|
-
catch (error) {
|
|
3677
|
-
this.logger.warn('Failed to reap AI-builder temporary workflow', {
|
|
3678
|
-
threadId,
|
|
3679
|
-
workflowId,
|
|
3680
|
-
error: getErrorMessage(error),
|
|
3681
|
-
});
|
|
3682
|
-
}
|
|
3683
|
-
}
|
|
3684
|
-
return archived;
|
|
3685
|
-
}
|
|
3686
3751
|
async finalizeCancelledSuspendedRun(suspended, reason = 'user_cancelled') {
|
|
3687
3752
|
const runTimeout = reason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON
|
|
3688
3753
|
? this.liveness.consumeRunTimeout(suspended.runId)
|
|
@@ -3694,7 +3759,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3694
3759
|
status: 'cancelled',
|
|
3695
3760
|
reason,
|
|
3696
3761
|
});
|
|
3697
|
-
const archivedWorkflowIds = await this.
|
|
3762
|
+
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(suspended.threadId, suspended.user, undefined, this.backgroundTasks.getRunningTasks(suspended.threadId).length);
|
|
3698
3763
|
this.publishRunFinish(suspended.threadId, suspended.runId, 'cancelled', reason, archivedWorkflowIds);
|
|
3699
3764
|
await this.saveAgentTreeSnapshot(suspended.threadId, suspended.runId, this.dbSnapshotStorage, true);
|
|
3700
3765
|
await this.maybeFinalizeRunTraceRoot(suspended.runId, {
|
|
@@ -3708,62 +3773,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3708
3773
|
});
|
|
3709
3774
|
void this.suspendedThreads.dropPendingConfirmation(suspended.requestId);
|
|
3710
3775
|
}
|
|
3711
|
-
async reapAiTemporaryForThreadCleanup(threadId) {
|
|
3712
|
-
let markedWorkflows;
|
|
3713
|
-
try {
|
|
3714
|
-
markedWorkflows = await this.aiBuilderTemporaryWorkflowRepository.findByThread(threadId);
|
|
3715
|
-
}
|
|
3716
|
-
catch (error) {
|
|
3717
|
-
this.logger.warn('Failed to inspect AI-builder temporary workflows during thread cleanup', {
|
|
3718
|
-
threadId,
|
|
3719
|
-
error: getErrorMessage(error),
|
|
3720
|
-
});
|
|
3721
|
-
return;
|
|
3722
|
-
}
|
|
3723
|
-
if (markedWorkflows.length === 0)
|
|
3724
|
-
return;
|
|
3725
|
-
let thread;
|
|
3726
|
-
try {
|
|
3727
|
-
thread = await this.threadRepo.findOneBy({ id: threadId });
|
|
3728
|
-
}
|
|
3729
|
-
catch (error) {
|
|
3730
|
-
this.logger.warn('Failed to load thread owner for AI-builder temporary workflow cleanup', {
|
|
3731
|
-
threadId,
|
|
3732
|
-
markedWorkflowCount: markedWorkflows.length,
|
|
3733
|
-
error: getErrorMessage(error),
|
|
3734
|
-
});
|
|
3735
|
-
return;
|
|
3736
|
-
}
|
|
3737
|
-
if (!thread?.resourceId) {
|
|
3738
|
-
this.logger.warn('Skipping AI-builder temporary workflow cleanup for thread without owner', {
|
|
3739
|
-
threadId,
|
|
3740
|
-
markedWorkflowCount: markedWorkflows.length,
|
|
3741
|
-
});
|
|
3742
|
-
return;
|
|
3743
|
-
}
|
|
3744
|
-
let user;
|
|
3745
|
-
try {
|
|
3746
|
-
user = await this.userRepository.findOneBy({ id: thread.resourceId });
|
|
3747
|
-
}
|
|
3748
|
-
catch (error) {
|
|
3749
|
-
this.logger.warn('Failed to load user for AI-builder temporary workflow cleanup', {
|
|
3750
|
-
threadId,
|
|
3751
|
-
userId: thread.resourceId,
|
|
3752
|
-
markedWorkflowCount: markedWorkflows.length,
|
|
3753
|
-
error: getErrorMessage(error),
|
|
3754
|
-
});
|
|
3755
|
-
return;
|
|
3756
|
-
}
|
|
3757
|
-
if (!user) {
|
|
3758
|
-
this.logger.warn('Skipping AI-builder temporary workflow cleanup for missing thread owner', {
|
|
3759
|
-
threadId,
|
|
3760
|
-
userId: thread.resourceId,
|
|
3761
|
-
markedWorkflowCount: markedWorkflows.length,
|
|
3762
|
-
});
|
|
3763
|
-
return;
|
|
3764
|
-
}
|
|
3765
|
-
await this.archiveAiTemporaryWorkflows(threadId, user, new Set(markedWorkflows.map(({ workflowId }) => workflowId)));
|
|
3766
|
-
}
|
|
3767
3776
|
publishRunFinish(threadId, runId, status, reason, archivedWorkflowIds) {
|
|
3768
3777
|
const effectiveStatus = status === 'errored' ? 'error' : status;
|
|
3769
3778
|
const hasArchived = archivedWorkflowIds && archivedWorkflowIds.length > 0;
|
|
@@ -3777,14 +3786,31 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3777
3786
|
...(hasArchived ? { archivedWorkflowIds } : {}),
|
|
3778
3787
|
},
|
|
3779
3788
|
});
|
|
3789
|
+
this.telemetry.track('instance_ai_run_finished', {
|
|
3790
|
+
thread_id: threadId,
|
|
3791
|
+
run_id: runId,
|
|
3792
|
+
status: effectiveStatus,
|
|
3793
|
+
});
|
|
3780
3794
|
}
|
|
3781
3795
|
async finalizeRun(threadId, runId, status, snapshotStorage, options) {
|
|
3782
3796
|
this.publishRunFinish(threadId, runId, status, undefined, options?.archivedWorkflowIds);
|
|
3797
|
+
this.emitRunMetrics(threadId, status, options);
|
|
3783
3798
|
await this.saveAgentTreeSnapshot(threadId, runId, snapshotStorage);
|
|
3784
3799
|
if (status === 'completed' && options?.userId && options?.modelId) {
|
|
3785
3800
|
void this.refineTitleIfNeeded(threadId, options.userId, options.modelId);
|
|
3786
3801
|
}
|
|
3787
3802
|
}
|
|
3803
|
+
emitRunMetrics(threadId, status, options) {
|
|
3804
|
+
const startedAt = this.runState.getActiveRun(threadId)?.startedAt;
|
|
3805
|
+
this.eventService.emit('instance-ai-run-finished', {
|
|
3806
|
+
status: status === 'errored' ? 'error' : status,
|
|
3807
|
+
durationMs: startedAt !== undefined ? Date.now() - startedAt : undefined,
|
|
3808
|
+
model: typeof options?.modelId === 'string' ? options.modelId : 'custom',
|
|
3809
|
+
toolCalls: options?.workSummary?.totalToolCalls ?? 0,
|
|
3810
|
+
toolErrors: options?.workSummary?.totalToolErrors ?? 0,
|
|
3811
|
+
...(options?.usage ? { usage: options.usage } : {}),
|
|
3812
|
+
});
|
|
3813
|
+
}
|
|
3788
3814
|
async refineTitleIfNeeded(threadId, userId, modelId) {
|
|
3789
3815
|
try {
|
|
3790
3816
|
const memory = this.agentMemory;
|
|
@@ -3975,8 +4001,7 @@ exports.InstanceAiService = InstanceAiService = __decorate([
|
|
|
3975
4001
|
typeorm_agent_memory_1.TypeORMAgentMemory,
|
|
3976
4002
|
typeorm_agent_checkpoint_store_1.TypeORMAgentCheckpointStore,
|
|
3977
4003
|
ai_service_1.AiService,
|
|
3978
|
-
|
|
3979
|
-
instance_ai_thread_repository_1.InstanceAiThreadRepository,
|
|
4004
|
+
instance_ai_thread_grant_repository_1.InstanceAiThreadGrantRepository,
|
|
3980
4005
|
instance_ai_pending_confirmation_repository_1.InstanceAiPendingConfirmationRepository,
|
|
3981
4006
|
url_service_1.UrlService,
|
|
3982
4007
|
db_snapshot_storage_1.DbSnapshotStorage,
|
|
@@ -3985,10 +4010,14 @@ exports.InstanceAiService = InstanceAiService = __decorate([
|
|
|
3985
4010
|
telemetry_1.Telemetry,
|
|
3986
4011
|
mcp_1.InstanceAiMcpRegistryService,
|
|
3987
4012
|
db_1.UserRepository,
|
|
3988
|
-
|
|
4013
|
+
instance_ai_temporary_workflow_service_1.InstanceAiTemporaryWorkflowService,
|
|
3989
4014
|
n8n_core_1.ErrorReporter,
|
|
3990
4015
|
config_1.SsrfProtectionConfig,
|
|
3991
4016
|
backend_network_1.SsrfProtectionService,
|
|
3992
|
-
event_service_1.EventService
|
|
4017
|
+
event_service_1.EventService,
|
|
4018
|
+
thread_credential_allowlist_service_1.EvalThreadCredentialAllowlistService,
|
|
4019
|
+
instance_ai_run_probe_1.InstanceAiRunProbe,
|
|
4020
|
+
instance_ai_model_service_1.InstanceAiModelService,
|
|
4021
|
+
instance_ai_credit_service_1.InstanceAiCreditService])
|
|
3993
4022
|
], InstanceAiService);
|
|
3994
4023
|
//# sourceMappingURL=instance-ai.service.js.map
|