n8n 2.23.2 → 2.25.1
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/active-workflow-manager.d.ts +8 -4
- package/dist/active-workflow-manager.js +26 -9
- package/dist/active-workflow-manager.js.map +1 -1
- package/dist/auth/auth.service.d.ts +1 -1
- package/dist/auth/auth.service.js +2 -1
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/controllers/ai.controller.js +1 -1
- package/dist/controllers/ai.controller.js.map +1 -1
- package/dist/controllers/api-keys.controller.d.ts +20 -15
- package/dist/controllers/api-keys.controller.js +7 -4
- package/dist/controllers/api-keys.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.d.ts +4 -2
- package/dist/controllers/oauth/oauth1-credential.controller.js +15 -5
- package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth2-credential.controller.d.ts +4 -2
- package/dist/controllers/oauth/oauth2-credential.controller.js +15 -6
- package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
- package/dist/controllers/project.controller.d.ts +8 -0
- package/dist/controllers/project.controller.js +2 -1
- package/dist/controllers/project.controller.js.map +1 -1
- package/dist/controllers/security-settings.controller.js +18 -1
- package/dist/controllers/security-settings.controller.js.map +1 -1
- package/dist/controllers/telemetry.controller.js +4 -1
- package/dist/controllers/telemetry.controller.js.map +1 -1
- package/dist/credentials/credential-connection-status-provider.interface.d.ts +3 -0
- package/dist/credentials/credential-connection-status-proxy.d.ts +3 -0
- package/dist/credentials/credential-connection-status-proxy.js +10 -0
- package/dist/credentials/credential-connection-status-proxy.js.map +1 -1
- package/dist/credentials/credentials.controller.d.ts +6 -0
- package/dist/credentials/credentials.controller.js +39 -2
- package/dist/credentials/credentials.controller.js.map +1 -1
- package/dist/credentials/credentials.service.d.ts +29 -13
- package/dist/credentials/credentials.service.ee.d.ts +2 -0
- package/dist/credentials/credentials.service.ee.js +3 -0
- package/dist/credentials/credentials.service.ee.js.map +1 -1
- package/dist/credentials/credentials.service.js +27 -6
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/credentials-helper.d.ts +1 -0
- package/dist/credentials-helper.js +14 -4
- package/dist/credentials-helper.js.map +1 -1
- package/dist/errors/credential-missing-id.error.d.ts +4 -0
- package/dist/errors/credential-missing-id.error.js +14 -0
- package/dist/errors/credential-missing-id.error.js.map +1 -0
- package/dist/eventbus/event-message-classes/index.d.ts +2 -2
- package/dist/eventbus/event-message-classes/index.js +3 -0
- package/dist/eventbus/event-message-classes/index.js.map +1 -1
- package/dist/events/maps/relay.event-map.d.ts +54 -2
- package/dist/events/relays/log-streaming.event-relay.d.ts +3 -0
- package/dist/events/relays/log-streaming.event-relay.js +39 -1
- package/dist/events/relays/log-streaming.event-relay.js.map +1 -1
- package/dist/events/relays/telemetry.event-relay.d.ts +6 -0
- package/dist/events/relays/telemetry.event-relay.js +74 -3
- package/dist/events/relays/telemetry.event-relay.js.map +1 -1
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js +6 -5
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
- package/dist/executions/execution-data/db-store.d.ts +1 -0
- package/dist/executions/execution-data/db-store.js +26 -0
- package/dist/executions/execution-data/db-store.js.map +1 -1
- package/dist/executions/execution-data/fs-store.d.ts +2 -0
- package/dist/executions/execution-data/fs-store.js +27 -0
- package/dist/executions/execution-data/fs-store.js.map +1 -1
- package/dist/executions/execution-data/types.d.ts +1 -0
- package/dist/executions/execution-persistence.d.ts +38 -4
- package/dist/executions/execution-persistence.js +127 -2
- package/dist/executions/execution-persistence.js.map +1 -1
- package/dist/expression-observability/expression-observability.provider.d.ts +3 -1
- package/dist/expression-observability/expression-observability.provider.js +48 -46
- package/dist/expression-observability/expression-observability.provider.js.map +1 -1
- package/dist/interfaces.d.ts +3 -1
- package/dist/modules/agents/agent-execution.service.d.ts +4 -2
- package/dist/modules/agents/agent-execution.service.js +3 -3
- package/dist/modules/agents/agent-execution.service.js.map +1 -1
- package/dist/modules/agents/agent-knowledge-command.service.d.ts +40 -0
- package/dist/modules/agents/agent-knowledge-command.service.js +221 -0
- package/dist/modules/agents/agent-knowledge-command.service.js.map +1 -0
- package/dist/modules/agents/agent-knowledge.service.d.ts +42 -0
- package/dist/modules/agents/agent-knowledge.service.js +300 -0
- package/dist/modules/agents/agent-knowledge.service.js.map +1 -0
- package/dist/modules/agents/agent-task.service.d.ts +52 -0
- package/dist/modules/agents/agent-task.service.js +487 -0
- package/dist/modules/agents/agent-task.service.js.map +1 -0
- package/dist/modules/agents/agent-upload.middleware.d.ts +7 -0
- package/dist/modules/agents/agent-upload.middleware.js +62 -0
- package/dist/modules/agents/agent-upload.middleware.js.map +1 -0
- package/dist/modules/agents/agents-tools.service.d.ts +1 -1
- package/dist/modules/agents/agents-tools.service.js +12 -3
- package/dist/modules/agents/agents-tools.service.js.map +1 -1
- package/dist/modules/agents/agents.controller.d.ts +138 -45
- package/dist/modules/agents/agents.controller.js +176 -48
- package/dist/modules/agents/agents.controller.js.map +1 -1
- package/dist/modules/agents/agents.module.d.ts +2 -2
- package/dist/modules/agents/agents.module.js +13 -5
- package/dist/modules/agents/agents.module.js.map +1 -1
- package/dist/modules/agents/agents.service.d.ts +43 -7
- package/dist/modules/agents/agents.service.js +341 -57
- package/dist/modules/agents/agents.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-prompts.d.ts +6 -5
- package/dist/modules/agents/builder/agents-builder-prompts.js +92 -18
- package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.d.ts +11 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.js +164 -26
- package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder.service.d.ts +3 -1
- package/dist/modules/agents/builder/agents-builder.service.js +8 -3
- package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
- package/dist/modules/agents/builder/builder-tool-names.d.ts +3 -0
- package/dist/modules/agents/builder/builder-tool-names.js +3 -0
- package/dist/modules/agents/builder/builder-tool-names.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-credential.tool.d.ts +1 -0
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js +25 -4
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-question.tool.js +6 -5
- package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -1
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +20 -5
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js +23 -4
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +18 -1
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -1
- package/dist/modules/agents/builder/prompts/memory.prompt.js +5 -3
- package/dist/modules/agents/builder/prompts/memory.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -1
- package/dist/modules/agents/builder/prompts/tools.prompt.js +11 -2
- package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -1
- package/dist/modules/agents/builder/search-mcp-servers.tool.d.ts +6 -0
- package/dist/modules/agents/builder/search-mcp-servers.tool.js +85 -0
- package/dist/modules/agents/builder/search-mcp-servers.tool.js.map +1 -0
- package/dist/modules/agents/builder/skill-body-template.d.ts +4 -0
- package/dist/modules/agents/builder/skill-body-template.js +31 -0
- package/dist/modules/agents/builder/skill-body-template.js.map +1 -0
- package/dist/modules/agents/builder/skills/index.js +6 -1
- package/dist/modules/agents/builder/skills/index.js.map +1 -1
- package/dist/modules/agents/builder/skills/integrations.skill.js +39 -18
- package/dist/modules/agents/builder/skills/integrations.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/mcp.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/mcp.skill.js +110 -0
- package/dist/modules/agents/builder/skills/mcp.skill.js.map +1 -0
- package/dist/modules/agents/builder/skills/research.skill.js +8 -5
- package/dist/modules/agents/builder/skills/research.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/target-skills.skill.js +41 -13
- package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/target-tasks.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/target-tasks.skill.js +82 -0
- package/dist/modules/agents/builder/skills/target-tasks.skill.js.map +1 -0
- package/dist/modules/agents/builder/task-objective-template.d.ts +3 -0
- package/dist/modules/agents/builder/task-objective-template.js +27 -0
- package/dist/modules/agents/builder/task-objective-template.js.map +1 -0
- package/dist/modules/agents/builder/verify-mcp-server.tool.d.ts +8 -0
- package/dist/modules/agents/builder/verify-mcp-server.tool.js +79 -0
- package/dist/modules/agents/builder/verify-mcp-server.tool.js.map +1 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.d.ts +4 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.js +26 -0
- package/dist/modules/agents/entities/agent-execution-thread.entity.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 +48 -0
- package/dist/modules/agents/entities/agent-file.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-task-run-lock.entity.d.ts +10 -0
- package/dist/modules/agents/entities/agent-task-run-lock.entity.js +54 -0
- package/dist/modules/agents/entities/agent-task-run-lock.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-task-snapshot.entity.d.ts +12 -0
- package/dist/modules/agents/entities/agent-task-snapshot.entity.js +70 -0
- package/dist/modules/agents/entities/agent-task-snapshot.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-task.entity.d.ts +11 -0
- package/dist/modules/agents/entities/agent-task.entity.js +64 -0
- package/dist/modules/agents/entities/agent-task.entity.js.map +1 -0
- package/dist/modules/agents/execution-recorder.d.ts +1 -0
- package/dist/modules/agents/execution-recorder.js +9 -5
- package/dist/modules/agents/execution-recorder.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +16 -4
- package/dist/modules/agents/integrations/agent-chat-bridge.js +372 -116
- package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-integration.d.ts +27 -2
- 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/chat-integration.service.d.ts +15 -6
- package/dist/modules/agents/integrations/chat-integration.service.js +9 -10
- package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -1
- package/dist/modules/agents/integrations/component-mapper.d.ts +14 -0
- package/dist/modules/agents/integrations/component-mapper.js +9 -1
- package/dist/modules/agents/integrations/component-mapper.js.map +1 -1
- package/dist/modules/agents/integrations/integration-action-executor.d.ts +22 -0
- package/dist/modules/agents/integrations/integration-action-executor.js +171 -0
- package/dist/modules/agents/integrations/integration-action-executor.js.map +1 -0
- package/dist/modules/agents/integrations/integration-context-query-executor.d.ts +18 -0
- package/dist/modules/agents/integrations/integration-context-query-executor.js +58 -0
- package/dist/modules/agents/integrations/integration-context-query-executor.js.map +1 -0
- package/dist/modules/agents/integrations/integration-error-codes.d.ts +13 -0
- package/dist/modules/agents/integrations/integration-error-codes.js +16 -0
- package/dist/modules/agents/integrations/integration-error-codes.js.map +1 -0
- package/dist/modules/agents/integrations/integration-helpers.d.ts +21 -0
- package/dist/modules/agents/integrations/integration-helpers.js +72 -0
- package/dist/modules/agents/integrations/integration-helpers.js.map +1 -0
- package/dist/modules/agents/integrations/integration-message-context.service.d.ts +13 -0
- package/dist/modules/agents/integrations/integration-message-context.service.js +129 -0
- package/dist/modules/agents/integrations/integration-message-context.service.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tools.d.ts +205 -0
- package/dist/modules/agents/integrations/integration-tools.js +955 -0
- package/dist/modules/agents/integrations/integration-tools.js.map +1 -0
- package/dist/modules/agents/integrations/integrations-sync.d.ts +1 -1
- package/dist/modules/agents/integrations/integrations-sync.js +1 -29
- package/dist/modules/agents/integrations/integrations-sync.js.map +1 -1
- package/dist/modules/agents/integrations/n8n-memory.d.ts +2 -0
- package/dist/modules/agents/integrations/n8n-memory.js +18 -11
- package/dist/modules/agents/integrations/n8n-memory.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-integration.d.ts +13 -2
- package/dist/modules/agents/integrations/platforms/linear-integration.js +70 -15
- package/dist/modules/agents/integrations/platforms/linear-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-operations.d.ts +18 -0
- package/dist/modules/agents/integrations/platforms/linear-operations.js +679 -0
- package/dist/modules/agents/integrations/platforms/linear-operations.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.d.ts +11 -1
- package/dist/modules/agents/integrations/platforms/slack-integration.js +53 -1
- package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-operations.d.ts +17 -0
- package/dist/modules/agents/integrations/platforms/slack-operations.js +288 -0
- package/dist/modules/agents/integrations/platforms/slack-operations.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.d.ts +9 -2
- package/dist/modules/agents/integrations/platforms/telegram-integration.js +17 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.js.map +1 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.js +7 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -1
- package/dist/modules/agents/json-config/from-json-config.d.ts +4 -2
- package/dist/modules/agents/json-config/from-json-config.js +88 -11
- package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
- package/dist/modules/agents/json-config/mcp-client-factory.d.ts +16 -0
- package/dist/modules/agents/json-config/mcp-client-factory.js +155 -0
- package/dist/modules/agents/json-config/mcp-client-factory.js.map +1 -0
- package/dist/modules/agents/json-config/native-web-search-provider-tools.d.ts +8 -0
- package/dist/modules/agents/json-config/native-web-search-provider-tools.js +59 -0
- package/dist/modules/agents/json-config/native-web-search-provider-tools.js.map +1 -0
- package/dist/modules/agents/json-config/schema-text-serializer.js +12 -2
- package/dist/modules/agents/json-config/schema-text-serializer.js.map +1 -1
- package/dist/modules/agents/repositories/agent-execution-thread.repository.d.ts +1 -1
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js +5 -3
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js.map +1 -1
- package/dist/modules/agents/repositories/agent-file.repository.d.ts +7 -0
- package/dist/modules/agents/repositories/agent-file.repository.js +35 -0
- package/dist/modules/agents/repositories/agent-file.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-history.repository.d.ts +2 -0
- package/dist/modules/agents/repositories/agent-history.repository.js +18 -0
- package/dist/modules/agents/repositories/agent-history.repository.js.map +1 -1
- package/dist/modules/agents/repositories/agent-task-run-lock.repository.d.ts +12 -0
- package/dist/modules/agents/repositories/agent-task-run-lock.repository.js +72 -0
- package/dist/modules/agents/repositories/agent-task-run-lock.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-task-snapshot.repository.d.ts +11 -0
- package/dist/modules/agents/repositories/agent-task-snapshot.repository.js +45 -0
- package/dist/modules/agents/repositories/agent-task-snapshot.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-task.repository.d.ts +7 -0
- package/dist/modules/agents/repositories/agent-task.repository.js +32 -0
- package/dist/modules/agents/repositories/agent-task.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent.repository.js +1 -2
- package/dist/modules/agents/repositories/agent.repository.js.map +1 -1
- package/dist/modules/agents/tools/knowledge/csv-helpers.d.ts +73 -0
- package/dist/modules/agents/tools/knowledge/csv-helpers.js +341 -0
- package/dist/modules/agents/tools/knowledge/csv-helpers.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/csv.operation.d.ts +61 -0
- package/dist/modules/agents/tools/knowledge/csv.operation.js +207 -0
- package/dist/modules/agents/tools/knowledge/csv.operation.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/file-references.d.ts +16 -0
- package/dist/modules/agents/tools/knowledge/file-references.js +35 -0
- package/dist/modules/agents/tools/knowledge/file-references.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/read.operation.d.ts +8 -0
- package/dist/modules/agents/tools/knowledge/read.operation.js +38 -0
- package/dist/modules/agents/tools/knowledge/read.operation.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/schemas.d.ts +1505 -0
- package/dist/modules/agents/tools/knowledge/schemas.js +441 -0
- package/dist/modules/agents/tools/knowledge/schemas.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/search.operation.d.ts +9 -0
- package/dist/modules/agents/tools/knowledge/search.operation.js +332 -0
- package/dist/modules/agents/tools/knowledge/search.operation.js.map +1 -0
- package/dist/modules/agents/tools/knowledge/tool.d.ts +8 -0
- package/dist/modules/agents/tools/knowledge/tool.js +121 -0
- package/dist/modules/agents/tools/knowledge/tool.js.map +1 -0
- package/dist/modules/agents/utils/agent-memory-scope.d.ts +1 -1
- package/dist/modules/agents/utils/agent-memory-scope.js +4 -4
- package/dist/modules/agents/utils/agent-memory-scope.js.map +1 -1
- package/dist/modules/agents/utils/agent-resource-id.d.ts +1 -1
- package/dist/modules/chat-hub/chat-hub.module.d.ts +2 -2
- package/dist/modules/chat-hub/chat-hub.settings.controller.d.ts +4 -4
- package/dist/modules/chat-hub/chat-hub.types.d.ts +5 -5
- package/dist/modules/chat-hub/dto/chat-models-request.dto.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/constants.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/constants.js +2 -1
- package/dist/modules/dynamic-credentials.ee/constants.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.d.ts +9 -2
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js +45 -14
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.controller.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.d.ts +4 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js +16 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js +6 -2
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.d.ts +1 -0
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js +21 -2
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js.map +1 -1
- package/dist/modules/instance-ai/eval/execution.service.d.ts +4 -1
- package/dist/modules/instance-ai/eval/execution.service.js +118 -24
- package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/llm-wire-server.d.ts +8 -3
- package/dist/modules/instance-ai/eval/llm-wire-server.js +147 -50
- package/dist/modules/instance-ai/eval/llm-wire-server.js.map +1 -1
- package/dist/modules/instance-ai/eval/mock-handler.js +45 -8
- package/dist/modules/instance-ai/eval/mock-handler.js.map +1 -1
- package/dist/modules/instance-ai/eval/mock-quirks.d.ts +4 -2
- package/dist/modules/instance-ai/eval/mock-quirks.js +83 -4
- package/dist/modules/instance-ai/eval/mock-quirks.js.map +1 -1
- package/dist/modules/instance-ai/eval/openai-envelope.d.ts +8 -0
- package/dist/modules/instance-ai/eval/openai-envelope.js +121 -8
- package/dist/modules/instance-ai/eval/openai-envelope.js.map +1 -1
- package/dist/modules/instance-ai/eval/openai-responses-envelope.d.ts +11 -0
- package/dist/modules/instance-ai/eval/openai-responses-envelope.js +238 -0
- package/dist/modules/instance-ai/eval/openai-responses-envelope.js.map +1 -0
- package/dist/modules/instance-ai/eval/request-binary-redactor.d.ts +1 -0
- package/dist/modules/instance-ai/eval/request-binary-redactor.js +74 -0
- package/dist/modules/instance-ai/eval/request-binary-redactor.js.map +1 -0
- package/dist/modules/instance-ai/eval/workflow-analysis.d.ts +19 -1
- package/dist/modules/instance-ai/eval/workflow-analysis.js +159 -76
- package/dist/modules/instance-ai/eval/workflow-analysis.js.map +1 -1
- package/dist/modules/instance-ai/extract-resolved-node-parameters.d.ts +7 -0
- package/dist/modules/instance-ai/extract-resolved-node-parameters.js +221 -0
- package/dist/modules/instance-ai/extract-resolved-node-parameters.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +7 -1
- package/dist/modules/instance-ai/instance-ai-memory.service.js +80 -3
- package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.js +1 -16
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +1 -1
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +67 -7
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +24 -1
- package/dist/modules/instance-ai/instance-ai.service.js +400 -26
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +1 -0
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +1 -0
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -1
- package/dist/modules/instance-ai/message-parser.d.ts +2 -0
- package/dist/modules/instance-ai/message-parser.js +165 -36
- package/dist/modules/instance-ai/message-parser.js.map +1 -1
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.d.ts +2 -0
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js +13 -0
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js.map +1 -1
- package/dist/modules/instance-ai/repositories/instance-ai-pending-confirmation.repository.d.ts +12 -0
- package/dist/modules/instance-ai/repositories/instance-ai-pending-confirmation.repository.js +80 -0
- package/dist/modules/instance-ai/repositories/instance-ai-pending-confirmation.repository.js.map +1 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.d.ts +1 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js +23 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js.map +1 -1
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.d.ts +10 -4
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js +49 -37
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js.map +1 -1
- package/dist/modules/instance-ai/web-research/index.d.ts +0 -2
- package/dist/modules/instance-ai/web-research/index.js +1 -5
- package/dist/modules/instance-ai/web-research/index.js.map +1 -1
- package/dist/modules/ldap.ee/helpers.ee.js +6 -2
- package/dist/modules/ldap.ee/helpers.ee.js.map +1 -1
- package/dist/modules/mcp/mcp.controller.js +13 -6
- package/dist/modules/mcp/mcp.controller.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +10 -2
- package/dist/modules/mcp/mcp.service.js +39 -6
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/mcp.settings.controller.d.ts +2 -0
- package/dist/modules/mcp/mcp.settings.service.d.ts +2 -0
- package/dist/modules/mcp/mcp.settings.service.js +6 -5
- package/dist/modules/mcp/mcp.settings.service.js.map +1 -1
- package/dist/modules/mcp/mcp.types.d.ts +6 -0
- package/dist/modules/mcp/mcp.types.js +9 -0
- package/dist/modules/mcp/mcp.types.js.map +1 -1
- package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +6 -6
- package/dist/modules/mcp/tools/search-workflows.tool.d.ts +2 -1
- package/dist/modules/mcp/tools/search-workflows.tool.js +12 -4
- package/dist/modules/mcp/tools/search-workflows.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/constants.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/constants.js +2 -1
- package/dist/modules/mcp/tools/workflow-builder/constants.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js +6 -4
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +67 -6
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.d.ts +30 -0
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.js +161 -0
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.js.map +1 -0
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.d.ts +67 -6
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js +51 -0
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js.map +1 -1
- package/dist/modules/mcp-registry/registry/mcp-registry.types.js.map +1 -1
- package/dist/modules/mcp-registry/synthesize-type-def.d.ts +2 -0
- package/dist/modules/mcp-registry/synthesize-type-def.js +35 -0
- package/dist/modules/mcp-registry/synthesize-type-def.js.map +1 -0
- package/dist/modules/n8n-packages/engine/import-pipeline.d.ts +24 -0
- package/dist/modules/n8n-packages/engine/import-pipeline.js +206 -0
- package/dist/modules/n8n-packages/engine/import-pipeline.js.map +1 -0
- package/dist/modules/n8n-packages/entities/credential/credential-requirements.extractor.d.ts +6 -0
- package/dist/modules/n8n-packages/entities/credential/credential-requirements.extractor.js +33 -0
- package/dist/modules/n8n-packages/entities/credential/credential-requirements.extractor.js.map +1 -0
- package/dist/modules/n8n-packages/entities/credential/credential.exporter.d.ts +23 -0
- package/dist/modules/n8n-packages/entities/credential/credential.exporter.js +68 -0
- package/dist/modules/n8n-packages/entities/credential/credential.exporter.js.map +1 -0
- package/dist/modules/n8n-packages/entities/credential/credential.serializer.d.ts +5 -0
- package/dist/modules/n8n-packages/entities/credential/credential.serializer.js +25 -0
- package/dist/modules/n8n-packages/entities/credential/credential.serializer.js.map +1 -0
- package/dist/modules/n8n-packages/entities/credential/credential.types.d.ts +6 -0
- package/dist/modules/n8n-packages/entities/credential/credential.types.js +3 -0
- package/dist/modules/n8n-packages/entities/credential/credential.types.js.map +1 -0
- package/dist/modules/n8n-packages/entities/requirements-extractor.d.ts +4 -0
- package/dist/modules/n8n-packages/entities/requirements-extractor.js +3 -0
- package/dist/modules/n8n-packages/entities/requirements-extractor.js.map +1 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.d.ts +12 -3
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js +11 -20
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js.map +1 -1
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.d.ts +3 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js +10 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js.map +1 -1
- package/dist/modules/n8n-packages/io/package-reader.d.ts +6 -0
- package/dist/modules/n8n-packages/io/package-reader.js +3 -0
- package/dist/modules/n8n-packages/io/package-reader.js.map +1 -0
- package/dist/modules/n8n-packages/io/slug.utils.d.ts +1 -1
- package/dist/modules/n8n-packages/io/slug.utils.js +3 -3
- package/dist/modules/n8n-packages/io/slug.utils.js.map +1 -1
- package/dist/modules/n8n-packages/io/tar/tar-package-reader.d.ts +13 -0
- package/dist/modules/n8n-packages/io/tar/tar-package-reader.js +84 -0
- package/dist/modules/n8n-packages/io/tar/tar-package-reader.js.map +1 -0
- package/dist/modules/n8n-packages/io/unique-filename-allocator.d.ts +7 -0
- package/dist/modules/n8n-packages/io/unique-filename-allocator.js +27 -0
- package/dist/modules/n8n-packages/io/unique-filename-allocator.js.map +1 -0
- package/dist/modules/n8n-packages/n8n-packages.service.d.ts +7 -2
- package/dist/modules/n8n-packages/n8n-packages.service.js +21 -3
- package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -1
- package/dist/modules/n8n-packages/n8n-packages.types.d.ts +22 -0
- package/dist/modules/n8n-packages/spec/manifest.schema.d.ts +121 -4
- package/dist/modules/n8n-packages/spec/manifest.schema.js +22 -3
- package/dist/modules/n8n-packages/spec/manifest.schema.js.map +1 -1
- package/dist/modules/n8n-packages/spec/requirements.schema.d.ts +51 -0
- package/dist/modules/n8n-packages/spec/requirements.schema.js +14 -0
- package/dist/modules/n8n-packages/spec/requirements.schema.js.map +1 -0
- package/dist/modules/n8n-packages/spec/serialized/credential.schema.d.ts +15 -0
- package/dist/modules/n8n-packages/spec/serialized/credential.schema.js +12 -0
- package/dist/modules/n8n-packages/spec/serialized/credential.schema.js.map +1 -0
- package/dist/modules/n8n-packages/spec/serialized/workflow.schema.d.ts +4 -4
- package/dist/modules/n8n-packages/utils/import-package-upload.d.ts +13 -0
- package/dist/modules/n8n-packages/utils/import-package-upload.js +59 -0
- package/dist/modules/n8n-packages/utils/import-package-upload.js.map +1 -0
- package/dist/modules/otel/execution-level-tracer.js +15 -6
- package/dist/modules/otel/execution-level-tracer.js.map +1 -1
- package/dist/modules/otel/execution-level-tracer.types.d.ts +3 -0
- package/dist/modules/otel/execution-level-tracer.types.js.map +1 -1
- package/dist/modules/otel/otel-lifecycle-handler.d.ts +4 -2
- package/dist/modules/otel/otel-lifecycle-handler.js +69 -4
- package/dist/modules/otel/otel-lifecycle-handler.js.map +1 -1
- package/dist/modules/otel/otel.config.d.ts +1 -0
- package/dist/modules/otel/otel.config.js +5 -0
- package/dist/modules/otel/otel.config.js.map +1 -1
- package/dist/modules/otel/otel.constants.d.ts +2 -0
- package/dist/modules/otel/otel.constants.js +2 -0
- package/dist/modules/otel/otel.constants.js.map +1 -1
- package/dist/modules/redaction/instance-redaction-enforcement.service.d.ts +4 -0
- package/dist/modules/redaction/instance-redaction-enforcement.service.js +8 -0
- package/dist/modules/redaction/instance-redaction-enforcement.service.js.map +1 -1
- package/dist/modules/redaction/redaction-context-hook.d.ts +9 -0
- package/dist/modules/redaction/redaction-context-hook.js +57 -0
- package/dist/modules/redaction/redaction-context-hook.js.map +1 -0
- package/dist/modules/redaction/redaction.module.js +1 -0
- package/dist/modules/redaction/redaction.module.js.map +1 -1
- package/dist/modules/source-control.ee/constants.d.ts +1 -0
- package/dist/modules/source-control.ee/constants.js +2 -1
- package/dist/modules/source-control.ee/constants.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-status.service.ee.js +5 -0
- package/dist/modules/source-control.ee/source-control-status.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +4 -2
- package/dist/modules/source-control.ee/source-control.controller.ee.js +32 -5
- package/dist/modules/source-control.ee/source-control.controller.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.service.ee.js +2 -0
- package/dist/modules/source-control.ee/source-control.service.ee.js.map +1 -1
- package/dist/modules/workflow-builder/workflow-builder-session.repository.js +2 -1
- package/dist/modules/workflow-builder/workflow-builder-session.repository.js.map +1 -1
- package/dist/node-catalog/node-catalog.service.d.ts +2 -0
- package/dist/node-catalog/node-catalog.service.js +38 -2
- package/dist/node-catalog/node-catalog.service.js.map +1 -1
- package/dist/oauth/oauth-browser-binding.service.d.ts +18 -0
- package/dist/oauth/oauth-browser-binding.service.js +68 -0
- package/dist/oauth/oauth-browser-binding.service.js.map +1 -0
- package/dist/oauth/oauth.service.d.ts +10 -4
- package/dist/oauth/oauth.service.js +87 -4
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/oauth/types.d.ts +1 -0
- package/dist/oauth/types.js.map +1 -1
- package/dist/public-api/index.js +5 -1
- package/dist/public-api/index.js.map +1 -1
- package/dist/public-api/types.d.ts +6 -0
- package/dist/public-api/v1/handlers/credentials/credentials.service.js +1 -0
- package/dist/public-api/v1/handlers/credentials/credentials.service.js.map +1 -1
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.d.ts +5 -0
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +22 -0
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -1
- package/dist/public-api/v1/openapi.yml +207 -59
- package/dist/requests.d.ts +4 -0
- package/dist/scaling/constants.d.ts +2 -2
- package/dist/scaling/pubsub/pubsub.event-map.d.ts +5 -2
- package/dist/scaling/pubsub/pubsub.types.d.ts +2 -1
- package/dist/services/ai-workflow-builder.service.d.ts +6 -3
- package/dist/services/ai-workflow-builder.service.js +13 -5
- package/dist/services/ai-workflow-builder.service.js.map +1 -1
- package/dist/services/api-key-auth.strategy.d.ts +4 -1
- package/dist/services/api-key-auth.strategy.js +18 -2
- package/dist/services/api-key-auth.strategy.js.map +1 -1
- package/dist/services/ownership.service.d.ts +1 -0
- package/dist/services/ownership.service.js +7 -0
- package/dist/services/ownership.service.js.map +1 -1
- package/dist/services/project.service.ee.d.ts +6 -2
- package/dist/services/project.service.ee.js +30 -8
- package/dist/services/project.service.ee.js.map +1 -1
- package/dist/services/public-api-key.service.d.ts +21 -14
- package/dist/services/public-api-key.service.js +14 -9
- package/dist/services/public-api-key.service.js.map +1 -1
- package/dist/telemetry/index.d.ts +6 -9
- package/dist/telemetry/index.js +23 -9
- package/dist/telemetry/index.js.map +1 -1
- package/dist/webhooks/constants.js +5 -1
- package/dist/webhooks/constants.js.map +1 -1
- package/dist/webhooks/live-webhooks.d.ts +8 -1
- package/dist/webhooks/live-webhooks.js +37 -22
- package/dist/webhooks/live-webhooks.js.map +1 -1
- package/dist/webhooks/waiting-forms.js +8 -1
- package/dist/webhooks/waiting-forms.js.map +1 -1
- package/dist/webhooks/webhook-helpers.d.ts +1 -1
- package/dist/webhooks/webhook-helpers.js +20 -10
- package/dist/webhooks/webhook-helpers.js.map +1 -1
- package/dist/webhooks/webhook-request-handler.js +1 -1
- package/dist/webhooks/webhook-request-handler.js.map +1 -1
- package/dist/workflow-helpers.d.ts +6 -1
- package/dist/workflow-helpers.js +9 -1
- package/dist/workflow-helpers.js.map +1 -1
- package/dist/workflows/workflow-creation.service.d.ts +4 -1
- package/dist/workflows/workflow-creation.service.js +12 -3
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow-execution.service.js +2 -0
- package/dist/workflows/workflow-execution.service.js.map +1 -1
- package/dist/workflows/workflow-finder.service.d.ts +1 -0
- package/dist/workflows/workflow-published-data.service.d.ts +11 -0
- package/dist/workflows/workflow-published-data.service.js +39 -0
- package/dist/workflows/workflow-published-data.service.js.map +1 -0
- package/dist/workflows/workflow-validation.service.d.ts +5 -1
- package/dist/workflows/workflow-validation.service.js +55 -2
- package/dist/workflows/workflow-validation.service.js.map +1 -1
- package/dist/workflows/workflow.service.js +4 -0
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.d.ts +8 -0
- package/package.json +45 -37
- package/templates/form-trigger-completion.handlebars +12 -1
- package/dist/modules/agents/integrations/agent-schedule.service.d.ts +0 -30
- package/dist/modules/agents/integrations/agent-schedule.service.js +0 -331
- package/dist/modules/agents/integrations/agent-schedule.service.js.map +0 -1
- package/dist/modules/instance-ai/web-research/brave-search.d.ts +0 -10
- package/dist/modules/instance-ai/web-research/brave-search.js +0 -44
- package/dist/modules/instance-ai/web-research/brave-search.js.map +0 -1
- package/dist/modules/instance-ai/web-research/searxng-search.d.ts +0 -6
- package/dist/modules/instance-ai/web-research/searxng-search.js +0 -39
- package/dist/modules/instance-ai/web-research/searxng-search.js.map +0 -1
|
@@ -73,6 +73,7 @@ const db_iteration_log_storage_1 = require("./storage/db-iteration-log-storage")
|
|
|
73
73
|
const typeorm_agent_checkpoint_store_1 = require("./storage/typeorm-agent-checkpoint-store");
|
|
74
74
|
const typeorm_agent_memory_1 = require("./storage/typeorm-agent-memory");
|
|
75
75
|
const proxy_token_manager_1 = require("../../services/proxy-token-manager");
|
|
76
|
+
const instance_ai_pending_confirmation_repository_1 = require("./repositories/instance-ai-pending-confirmation.repository");
|
|
76
77
|
const instance_ai_thread_repository_1 = require("./repositories/instance-ai-thread.repository");
|
|
77
78
|
const trace_replay_state_1 = require("./trace-replay-state");
|
|
78
79
|
const liveness_1 = require("./liveness");
|
|
@@ -86,6 +87,7 @@ function isTelemetryConfigurableAgent(agent) {
|
|
|
86
87
|
typeof Reflect.get(agent, 'telemetry') === 'function');
|
|
87
88
|
}
|
|
88
89
|
const INSTANCE_AI_CHECKPOINT_PRUNE_RETRY_MS = 30 * 1000;
|
|
90
|
+
const INSTANCE_AI_SHUTDOWN_DRAIN_TIMEOUT_MS = 5 * 1000;
|
|
89
91
|
function isTextMessagePart(part) {
|
|
90
92
|
return (typeof part === 'object' &&
|
|
91
93
|
part !== null &&
|
|
@@ -331,7 +333,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
331
333
|
}
|
|
332
334
|
return this._mcpClientManager;
|
|
333
335
|
}
|
|
334
|
-
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, agentMemory, checkpointStore, aiService, push, threadRepo, urlService, dbSnapshotStorage, dbIterationLogStorage, sourceControlPreferencesService, telemetry, userRepository, aiBuilderTemporaryWorkflowRepository, errorReporter, ssrfProtectionConfig, ssrfProtectionService, eventService) {
|
|
336
|
+
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, agentMemory, checkpointStore, aiService, push, threadRepo, pendingConfirmationRepo, urlService, dbSnapshotStorage, dbIterationLogStorage, sourceControlPreferencesService, telemetry, userRepository, aiBuilderTemporaryWorkflowRepository, errorReporter, ssrfProtectionConfig, ssrfProtectionService, eventService) {
|
|
335
337
|
this.instanceSettings = instanceSettings;
|
|
336
338
|
this.adapterService = adapterService;
|
|
337
339
|
this.eventBus = eventBus;
|
|
@@ -341,6 +343,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
341
343
|
this.aiService = aiService;
|
|
342
344
|
this.push = push;
|
|
343
345
|
this.threadRepo = threadRepo;
|
|
346
|
+
this.pendingConfirmationRepo = pendingConfirmationRepo;
|
|
344
347
|
this.urlService = urlService;
|
|
345
348
|
this.dbSnapshotStorage = dbSnapshotStorage;
|
|
346
349
|
this.dbIterationLogStorage = dbIterationLogStorage;
|
|
@@ -364,6 +367,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
364
367
|
this.creditedThreads = new Set();
|
|
365
368
|
this.traceReplay = new trace_replay_state_1.TraceReplayState();
|
|
366
369
|
this.checkpointPruningStopped = true;
|
|
370
|
+
this.inFlightExecutions = new Set();
|
|
371
|
+
this.preserveHitlOnShutdown = new Set();
|
|
372
|
+
this.userMessagePersistenceByRun = new Map();
|
|
367
373
|
this.logger = logger.scoped('instance-ai');
|
|
368
374
|
this.instanceAiConfig = globalConfig.instanceAi;
|
|
369
375
|
const livenessPolicyConfig = (0, instance_ai_1.createInstanceAiLivenessPolicyConfig)({
|
|
@@ -379,6 +385,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
379
385
|
finalizeCancelledSuspendedRun: (suspended, reason) => {
|
|
380
386
|
void this.finalizeCancelledSuspendedRun(suspended, reason);
|
|
381
387
|
},
|
|
388
|
+
onPendingConfirmationRejected: (requestId) => {
|
|
389
|
+
void this.dropPendingConfirmation(requestId);
|
|
390
|
+
},
|
|
382
391
|
});
|
|
383
392
|
this.defaultTimeZone = globalConfig.generic.timezone;
|
|
384
393
|
const restEndpoint = globalConfig.endpoints.rest;
|
|
@@ -1036,7 +1045,12 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1036
1045
|
if (pushRef !== undefined) {
|
|
1037
1046
|
this.threadPushRef.set(threadId, pushRef);
|
|
1038
1047
|
}
|
|
1039
|
-
|
|
1048
|
+
const userMessageId = (0, nanoid_1.nanoid)();
|
|
1049
|
+
this.userMessagePersistenceByRun.set(runId, {
|
|
1050
|
+
userId: user.id,
|
|
1051
|
+
message: { id: userMessageId, text: message },
|
|
1052
|
+
});
|
|
1053
|
+
this.startExecuteRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone, false, undefined, undefined);
|
|
1040
1054
|
return runId;
|
|
1041
1055
|
}
|
|
1042
1056
|
getMessageGroupId(threadId) {
|
|
@@ -1079,6 +1093,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1079
1093
|
if (reason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON)
|
|
1080
1094
|
this.liveness.markRunTimedOut(active.runId);
|
|
1081
1095
|
active.abortController.abort();
|
|
1096
|
+
void this.dropPendingConfirmationsForThread(threadId);
|
|
1082
1097
|
return;
|
|
1083
1098
|
}
|
|
1084
1099
|
if (suspended) {
|
|
@@ -1087,6 +1102,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1087
1102
|
suspended.abortController.abort();
|
|
1088
1103
|
void this.finalizeCancelledSuspendedRun(suspended, reason);
|
|
1089
1104
|
}
|
|
1105
|
+
void this.dropPendingConfirmationsForThread(threadId);
|
|
1090
1106
|
}
|
|
1091
1107
|
sendCorrectionToTask(threadId, taskId, correction) {
|
|
1092
1108
|
return this.backgroundTasks.queueCorrection(threadId, taskId, correction);
|
|
@@ -1317,30 +1333,44 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1317
1333
|
this.deleteTraceContextsForThread(threadId);
|
|
1318
1334
|
await this.destroySandbox(threadId);
|
|
1319
1335
|
await this.reapAiTemporaryForThreadCleanup(threadId);
|
|
1336
|
+
await this.dropPendingConfirmationsForThread(threadId);
|
|
1320
1337
|
this.eventBus.clearThread(threadId);
|
|
1321
1338
|
}
|
|
1322
1339
|
async shutdown() {
|
|
1323
1340
|
this.stopCheckpointPruning();
|
|
1324
1341
|
this.liveness.shutdown();
|
|
1325
|
-
const { activeRuns, suspendedRuns } = this.runState.shutdown();
|
|
1342
|
+
const { activeRuns, suspendedRuns, pendingThreadIds } = this.runState.shutdown();
|
|
1343
|
+
const threadsWithPendingHitl = new Set(pendingThreadIds);
|
|
1326
1344
|
for (const run of activeRuns) {
|
|
1327
|
-
run.
|
|
1345
|
+
if (threadsWithPendingHitl.has(run.threadId)) {
|
|
1346
|
+
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
1347
|
+
status: 'cancelled',
|
|
1348
|
+
reason: 'service_shutdown',
|
|
1349
|
+
});
|
|
1350
|
+
this.preserveHitlOnShutdown.add(run.runId);
|
|
1351
|
+
run.abortController.abort();
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
this.publishRunFinish(run.threadId, run.runId, 'cancelled', 'service_shutdown');
|
|
1355
|
+
await this.persistShutdownSnapshot(run.threadId, run.runId, run.messageGroupId);
|
|
1328
1356
|
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
1329
1357
|
status: 'cancelled',
|
|
1330
1358
|
reason: 'service_shutdown',
|
|
1331
1359
|
});
|
|
1360
|
+
run.abortController.abort();
|
|
1332
1361
|
}
|
|
1333
1362
|
for (const run of suspendedRuns) {
|
|
1334
|
-
run.abortController.abort();
|
|
1335
1363
|
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
1336
1364
|
status: 'cancelled',
|
|
1337
1365
|
reason: 'service_shutdown',
|
|
1338
1366
|
});
|
|
1367
|
+
run.abortController.abort();
|
|
1339
1368
|
}
|
|
1340
1369
|
for (const task of this.backgroundTasks.cancelAll()) {
|
|
1341
1370
|
task.abortController.abort();
|
|
1342
1371
|
await this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
1343
1372
|
}
|
|
1373
|
+
await this.drainInFlightExecutions(INSTANCE_AI_SHUTDOWN_DRAIN_TIMEOUT_MS);
|
|
1344
1374
|
const threadsWithTraces = new Set([...this.traceContextsByRunId.values()].map((entry) => entry.threadId));
|
|
1345
1375
|
for (const threadId of threadsWithTraces) {
|
|
1346
1376
|
await this.finalizeRemainingMessageTraceRoots(threadId, {
|
|
@@ -1376,28 +1406,168 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1376
1406
|
}, delayMs);
|
|
1377
1407
|
this.checkpointPruneTimer.unref();
|
|
1378
1408
|
}
|
|
1409
|
+
trackInFlightExecution(promise) {
|
|
1410
|
+
const tracked = promise.finally(() => {
|
|
1411
|
+
this.inFlightExecutions.delete(tracked);
|
|
1412
|
+
});
|
|
1413
|
+
this.inFlightExecutions.add(tracked);
|
|
1414
|
+
}
|
|
1415
|
+
startExecuteRun(...args) {
|
|
1416
|
+
this.trackInFlightExecution(this.executeRun(...args));
|
|
1417
|
+
}
|
|
1418
|
+
startProcessResumedStream(...args) {
|
|
1419
|
+
this.trackInFlightExecution(this.processResumedStream(...args));
|
|
1420
|
+
}
|
|
1421
|
+
shouldPreserveHitlOnShutdown(runId) {
|
|
1422
|
+
return this.preserveHitlOnShutdown.has(runId);
|
|
1423
|
+
}
|
|
1424
|
+
async persistUserMessageOnFirstSuspend(threadId, runId) {
|
|
1425
|
+
const entry = this.userMessagePersistenceByRun.get(runId);
|
|
1426
|
+
if (!entry)
|
|
1427
|
+
return;
|
|
1428
|
+
const ok = await this.persistUserMessageOnSuspend(threadId, entry.userId, entry.message);
|
|
1429
|
+
if (ok)
|
|
1430
|
+
this.userMessagePersistenceByRun.delete(runId);
|
|
1431
|
+
}
|
|
1432
|
+
async drainInFlightExecutions(timeoutMs) {
|
|
1433
|
+
if (this.inFlightExecutions.size === 0)
|
|
1434
|
+
return;
|
|
1435
|
+
const drain = Promise.allSettled([...this.inFlightExecutions]);
|
|
1436
|
+
const timeout = new Promise((resolve) => {
|
|
1437
|
+
setTimeout(() => resolve('timeout'), timeoutMs).unref();
|
|
1438
|
+
});
|
|
1439
|
+
const outcome = await Promise.race([drain.then(() => 'drained'), timeout]);
|
|
1440
|
+
if (outcome === 'timeout') {
|
|
1441
|
+
this.logger.warn('Timed out waiting for in-flight Instance AI runs to drain', {
|
|
1442
|
+
timeoutMs,
|
|
1443
|
+
stillInFlight: this.inFlightExecutions.size,
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1379
1447
|
async pruneStaleCheckpoints(now = Date.now()) {
|
|
1380
1448
|
const olderThan = new Date(now - this.instanceAiConfig.snapshotRetention);
|
|
1381
1449
|
try {
|
|
1382
|
-
const count = await this.checkpointStore.
|
|
1450
|
+
const count = await this.checkpointStore.markExpiredOlderThan(olderThan);
|
|
1383
1451
|
if (count > 0) {
|
|
1384
|
-
this.logger.info('
|
|
1452
|
+
this.logger.info('Expired stale Instance AI checkpoints', { count });
|
|
1385
1453
|
}
|
|
1386
1454
|
else {
|
|
1387
|
-
this.logger.debug('No stale Instance AI checkpoints to
|
|
1455
|
+
this.logger.debug('No stale Instance AI checkpoints to expire');
|
|
1388
1456
|
}
|
|
1457
|
+
await this.pruneStalePendingConfirmations(now);
|
|
1389
1458
|
this.scheduleCheckpointPrune();
|
|
1390
1459
|
}
|
|
1391
1460
|
catch (error) {
|
|
1392
|
-
this.logger.warn('Failed to
|
|
1461
|
+
this.logger.warn('Failed to expire stale Instance AI checkpoints', {
|
|
1393
1462
|
error: getErrorMessage(error),
|
|
1394
1463
|
});
|
|
1395
1464
|
this.scheduleCheckpointPrune(INSTANCE_AI_CHECKPOINT_PRUNE_RETRY_MS);
|
|
1396
1465
|
}
|
|
1397
1466
|
}
|
|
1467
|
+
async pruneStalePendingConfirmations(now) {
|
|
1468
|
+
try {
|
|
1469
|
+
const count = await this.pendingConfirmationRepo.deleteExpired(new Date(now));
|
|
1470
|
+
if (count === 0) {
|
|
1471
|
+
this.logger.debug('No stale Instance AI pending confirmations to drop');
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
this.logger.info('Dropped stale Instance AI pending confirmations', { count });
|
|
1475
|
+
}
|
|
1476
|
+
catch (error) {
|
|
1477
|
+
this.logger.warn('Failed to drop stale Instance AI pending confirmations', {
|
|
1478
|
+
error: getErrorMessage(error),
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
computePendingConfirmationExpiresAt() {
|
|
1483
|
+
const timeoutMs = this.instanceAiConfig.confirmationTimeout;
|
|
1484
|
+
return timeoutMs > 0 ? new Date(Date.now() + timeoutMs) : null;
|
|
1485
|
+
}
|
|
1486
|
+
async persistPendingConfirmation(params) {
|
|
1487
|
+
try {
|
|
1488
|
+
await this.pendingConfirmationRepo.save(this.pendingConfirmationRepo.create({
|
|
1489
|
+
requestId: params.requestId,
|
|
1490
|
+
threadId: params.threadId,
|
|
1491
|
+
userId: params.userId,
|
|
1492
|
+
kind: params.kind,
|
|
1493
|
+
runId: params.runId,
|
|
1494
|
+
messageGroupId: params.messageGroupId ?? null,
|
|
1495
|
+
toolCallId: params.toolCallId ?? null,
|
|
1496
|
+
checkpointKey: params.checkpointKey ?? null,
|
|
1497
|
+
checkpointTaskId: params.checkpointTaskId ?? null,
|
|
1498
|
+
expiresAt: this.computePendingConfirmationExpiresAt(),
|
|
1499
|
+
}));
|
|
1500
|
+
}
|
|
1501
|
+
catch (error) {
|
|
1502
|
+
this.logger.warn('Failed to persist pending confirmation', {
|
|
1503
|
+
requestId: params.requestId,
|
|
1504
|
+
threadId: params.threadId,
|
|
1505
|
+
kind: params.kind,
|
|
1506
|
+
error: getErrorMessage(error),
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
async dropPendingConfirmation(requestId) {
|
|
1511
|
+
try {
|
|
1512
|
+
await this.pendingConfirmationRepo.deleteByRequestId(requestId);
|
|
1513
|
+
}
|
|
1514
|
+
catch (error) {
|
|
1515
|
+
this.logger.warn('Failed to drop pending confirmation', {
|
|
1516
|
+
requestId,
|
|
1517
|
+
error: getErrorMessage(error),
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
async dropPendingConfirmationsForThread(threadId) {
|
|
1522
|
+
try {
|
|
1523
|
+
await this.pendingConfirmationRepo.deleteByThreadId(threadId);
|
|
1524
|
+
}
|
|
1525
|
+
catch (error) {
|
|
1526
|
+
this.logger.warn('Failed to drop pending confirmations for thread', {
|
|
1527
|
+
threadId,
|
|
1528
|
+
error: getErrorMessage(error),
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
async persistUserMessageOnSuspend(threadId, userId, message) {
|
|
1533
|
+
try {
|
|
1534
|
+
await this.agentMemory.saveMessages({
|
|
1535
|
+
threadId,
|
|
1536
|
+
resourceId: userId,
|
|
1537
|
+
messages: [
|
|
1538
|
+
{
|
|
1539
|
+
id: message.id,
|
|
1540
|
+
role: 'user',
|
|
1541
|
+
content: [{ type: 'text', text: message.text }],
|
|
1542
|
+
createdAt: new Date(),
|
|
1543
|
+
},
|
|
1544
|
+
],
|
|
1545
|
+
});
|
|
1546
|
+
return true;
|
|
1547
|
+
}
|
|
1548
|
+
catch (error) {
|
|
1549
|
+
this.logger.warn('Failed to persist user message on HITL suspend', {
|
|
1550
|
+
threadId,
|
|
1551
|
+
userId,
|
|
1552
|
+
error: getErrorMessage(error),
|
|
1553
|
+
});
|
|
1554
|
+
return false;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
async persistShutdownSnapshot(threadId, runId, messageGroupId) {
|
|
1558
|
+
try {
|
|
1559
|
+
await this.saveAgentTreeSnapshot(threadId, runId, this.dbSnapshotStorage, true, messageGroupId);
|
|
1560
|
+
}
|
|
1561
|
+
catch (error) {
|
|
1562
|
+
this.logger.warn('Failed to persist shutdown snapshot', {
|
|
1563
|
+
threadId,
|
|
1564
|
+
runId,
|
|
1565
|
+
error: getErrorMessage(error),
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1398
1569
|
createAgentMemoryOptions() {
|
|
1399
1570
|
return {
|
|
1400
|
-
lastMessages: this.instanceAiConfig.lastMessages,
|
|
1401
1571
|
observationalMemory: {
|
|
1402
1572
|
observerThresholdTokens: this.instanceAiConfig.observerMessageTokens,
|
|
1403
1573
|
reflectorThresholdTokens: this.instanceAiConfig.reflectorObservationTokens,
|
|
@@ -1545,6 +1715,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1545
1715
|
}
|
|
1546
1716
|
async finishInvalidConfirmationRun(args) {
|
|
1547
1717
|
this.runState.cancelThread(args.threadId);
|
|
1718
|
+
void this.dropPendingConfirmationsForThread(args.threadId);
|
|
1548
1719
|
args.abortController.abort();
|
|
1549
1720
|
await this.finalizeRunTracing(args.runId, args.tracing, {
|
|
1550
1721
|
status: 'error',
|
|
@@ -1932,9 +2103,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1932
2103
|
abortSignal,
|
|
1933
2104
|
taskStorage,
|
|
1934
2105
|
timeZone: this.defaultTimeZone,
|
|
1935
|
-
browserMcpConfig: this.instanceAiConfig.browserMcp
|
|
1936
|
-
? { name: 'chrome-devtools', command: 'npx', args: ['-y', 'chrome-devtools-mcp@latest'] }
|
|
1937
|
-
: undefined,
|
|
1938
2106
|
localMcpServer: context.localMcpServer,
|
|
1939
2107
|
runtimeSkills,
|
|
1940
2108
|
runtimeSkillCatalog: baseRuntimeSkills,
|
|
@@ -1943,6 +2111,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1943
2111
|
formBaseUrl: this.formBaseUrl,
|
|
1944
2112
|
waitForConfirmation: async (requestId) => {
|
|
1945
2113
|
this.runState.touchActiveRun(threadId);
|
|
2114
|
+
void this.persistUserMessageOnFirstSuspend(threadId, runId);
|
|
1946
2115
|
return await new Promise((resolve) => {
|
|
1947
2116
|
this.runState.registerPendingConfirmation(requestId, {
|
|
1948
2117
|
resolve,
|
|
@@ -1950,6 +2119,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1950
2119
|
userId: user.id,
|
|
1951
2120
|
createdAt: Date.now(),
|
|
1952
2121
|
});
|
|
2122
|
+
void this.persistPendingConfirmation({
|
|
2123
|
+
requestId,
|
|
2124
|
+
threadId,
|
|
2125
|
+
userId: user.id,
|
|
2126
|
+
runId,
|
|
2127
|
+
messageGroupId,
|
|
2128
|
+
kind: 'inline',
|
|
2129
|
+
});
|
|
1953
2130
|
queueMicrotask(() => {
|
|
1954
2131
|
void this.saveAgentTreeSnapshot(threadId, runId, snapshotStorage);
|
|
1955
2132
|
});
|
|
@@ -1963,6 +2140,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1963
2140
|
schedulePlannedTasks: async () => await this.schedulePlannedTasks(user, threadId),
|
|
1964
2141
|
iterationLog,
|
|
1965
2142
|
sendCorrectionToTask: (taskId, correction) => this.sendCorrectionToTask(threadId, taskId, correction),
|
|
2143
|
+
findSubAgentResumeInfo: async (agentKind) => await this.checkpointStore.findSuspendedSubAgentResumeInfo((0, instance_ai_1.createSubAgentResourceId)(threadId, agentKind)),
|
|
2144
|
+
persistInFlightUserMessage: async () => {
|
|
2145
|
+
await this.persistUserMessageOnFirstSuspend(threadId, runId);
|
|
2146
|
+
},
|
|
1966
2147
|
workflowTaskService: workflowTasks,
|
|
1967
2148
|
workspace: runtimeWorkspace,
|
|
1968
2149
|
nodeDefinitionDirs: nodeDefDirs.length > 0 ? nodeDefDirs : undefined,
|
|
@@ -2102,7 +2283,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2102
2283
|
: isReplanFollowUp
|
|
2103
2284
|
? 'replan'
|
|
2104
2285
|
: 'background_task_completed';
|
|
2105
|
-
|
|
2286
|
+
this.startExecuteRun(user, threadId, runId, message, abortController, undefined, messageGroupId, timeZone, isReplanFollowUp, checkpoint, resumeReason);
|
|
2106
2287
|
return runId;
|
|
2107
2288
|
}
|
|
2108
2289
|
async schedulePlannedTasks(user, threadId) {
|
|
@@ -2178,6 +2359,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2178
2359
|
await this.doSchedulePlannedTasks(activeUser, threadId);
|
|
2179
2360
|
}
|
|
2180
2361
|
async executeRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone, isReplanFollowUp = false, checkpoint, resumeReason) {
|
|
2362
|
+
const userMessagePersistence = this.userMessagePersistenceByRun.get(runId)?.message;
|
|
2181
2363
|
const signal = abortController.signal;
|
|
2182
2364
|
let tracing;
|
|
2183
2365
|
let messageTraceFinalization;
|
|
@@ -2326,18 +2508,20 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2326
2508
|
: undefined;
|
|
2327
2509
|
let streamInput;
|
|
2328
2510
|
try {
|
|
2329
|
-
if (nonStructuredAttachments.length > 0) {
|
|
2511
|
+
if (nonStructuredAttachments.length > 0 || userMessagePersistence) {
|
|
2512
|
+
const baseContent = [
|
|
2513
|
+
{ type: 'text', text: fullMessage },
|
|
2514
|
+
...nonStructuredAttachments.map((attachment) => ({
|
|
2515
|
+
type: 'file',
|
|
2516
|
+
data: attachment.data,
|
|
2517
|
+
mediaType: attachment.mimeType,
|
|
2518
|
+
})),
|
|
2519
|
+
];
|
|
2330
2520
|
streamInput = [
|
|
2331
2521
|
{
|
|
2522
|
+
...(userMessagePersistence ? { id: userMessagePersistence.id } : {}),
|
|
2332
2523
|
role: 'user',
|
|
2333
|
-
content:
|
|
2334
|
-
{ type: 'text', text: fullMessage },
|
|
2335
|
-
...nonStructuredAttachments.map((attachment) => ({
|
|
2336
|
-
type: 'file',
|
|
2337
|
-
data: attachment.data,
|
|
2338
|
-
mediaType: attachment.mimeType,
|
|
2339
|
-
})),
|
|
2340
|
-
],
|
|
2524
|
+
content: baseContent,
|
|
2341
2525
|
},
|
|
2342
2526
|
];
|
|
2343
2527
|
}
|
|
@@ -2451,6 +2635,17 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2451
2635
|
modelId,
|
|
2452
2636
|
checkpoint,
|
|
2453
2637
|
});
|
|
2638
|
+
void this.persistPendingConfirmation({
|
|
2639
|
+
requestId: result.suspension.requestId,
|
|
2640
|
+
threadId,
|
|
2641
|
+
userId: user.id,
|
|
2642
|
+
runId,
|
|
2643
|
+
messageGroupId,
|
|
2644
|
+
kind: 'suspended',
|
|
2645
|
+
toolCallId: result.suspension.toolCallId,
|
|
2646
|
+
checkpointKey: result.agentRunId,
|
|
2647
|
+
checkpointTaskId: checkpoint?.checkpointTaskId,
|
|
2648
|
+
});
|
|
2454
2649
|
}
|
|
2455
2650
|
const intermediateText = await (result.text ?? Promise.resolve(''));
|
|
2456
2651
|
if (intermediateText) {
|
|
@@ -2518,6 +2713,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2518
2713
|
};
|
|
2519
2714
|
return;
|
|
2520
2715
|
}
|
|
2716
|
+
if (result.status === 'cancelled' && this.shouldPreserveHitlOnShutdown(runId)) {
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2521
2719
|
const outputText = await (result.text ?? Promise.resolve(''));
|
|
2522
2720
|
this.evaluateTerminalResponse(threadId, runId, result.status, {
|
|
2523
2721
|
messageGroupId,
|
|
@@ -2555,6 +2753,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2555
2753
|
}
|
|
2556
2754
|
catch (error) {
|
|
2557
2755
|
if (signal.aborted) {
|
|
2756
|
+
if (this.shouldPreserveHitlOnShutdown(runId)) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2558
2759
|
const runTimeout = this.liveness.consumeRunTimeout(runId);
|
|
2559
2760
|
const cancellationReason = runTimeout.timedOut
|
|
2560
2761
|
? liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON
|
|
@@ -2624,6 +2825,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2624
2825
|
}
|
|
2625
2826
|
finally {
|
|
2626
2827
|
this.runState.clearActiveRun(threadId);
|
|
2828
|
+
this.userMessagePersistenceByRun.delete(runId);
|
|
2627
2829
|
this.domainAccessTrackersByThread.get(threadId)?.clearRun(runId);
|
|
2628
2830
|
if (messageTraceFinalization) {
|
|
2629
2831
|
await this.maybeFinalizeRunTraceRoot(runId, messageTraceFinalization);
|
|
@@ -2764,6 +2966,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2764
2966
|
return false;
|
|
2765
2967
|
}
|
|
2766
2968
|
if (this.runState.resolvePendingConfirmation(freshUser.id, requestId, data)) {
|
|
2969
|
+
void this.dropPendingConfirmation(requestId);
|
|
2767
2970
|
this.logger.debug('Resolved pending confirmation (sub-agent HITL)', {
|
|
2768
2971
|
requestId,
|
|
2769
2972
|
approved: data.approved,
|
|
@@ -2774,7 +2977,157 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2774
2977
|
requestId,
|
|
2775
2978
|
approved: data.approved,
|
|
2776
2979
|
});
|
|
2777
|
-
|
|
2980
|
+
if (await this.resumeSuspendedRun(requestingUserId, requestId, data)) {
|
|
2981
|
+
return true;
|
|
2982
|
+
}
|
|
2983
|
+
return await this.resolveOrphanedConfirmation(requestingUserId, requestId, data);
|
|
2984
|
+
}
|
|
2985
|
+
async resolveOrphanedConfirmation(userId, requestId, data) {
|
|
2986
|
+
let orphan;
|
|
2987
|
+
try {
|
|
2988
|
+
orphan = await this.pendingConfirmationRepo.claim(requestId, userId);
|
|
2989
|
+
}
|
|
2990
|
+
catch (error) {
|
|
2991
|
+
this.logger.warn('Failed to claim orphaned pending confirmation', {
|
|
2992
|
+
requestId,
|
|
2993
|
+
error: getErrorMessage(error),
|
|
2994
|
+
});
|
|
2995
|
+
return false;
|
|
2996
|
+
}
|
|
2997
|
+
if (!orphan)
|
|
2998
|
+
return false;
|
|
2999
|
+
this.logger.info('Reclaiming pending confirmation orphaned by a process restart', {
|
|
3000
|
+
requestId,
|
|
3001
|
+
threadId: orphan.threadId,
|
|
3002
|
+
runId: orphan.runId,
|
|
3003
|
+
kind: orphan.kind,
|
|
3004
|
+
hasCheckpoint: Boolean(orphan.checkpointKey),
|
|
3005
|
+
});
|
|
3006
|
+
if (orphan.kind === 'suspended' && this.canResumeOrphan(orphan)) {
|
|
3007
|
+
const resumed = await this.tryResumeFromOrphan(orphan, data);
|
|
3008
|
+
if (resumed)
|
|
3009
|
+
return true;
|
|
3010
|
+
}
|
|
3011
|
+
this.finalizeUnresumableOrphan(orphan);
|
|
3012
|
+
throw new n8n_workflow_1.UserError('This confirmation was lost when the assistant restarted. Send a new message to continue.');
|
|
3013
|
+
}
|
|
3014
|
+
canResumeOrphan(orphan) {
|
|
3015
|
+
return Boolean(orphan.toolCallId && orphan.checkpointKey);
|
|
3016
|
+
}
|
|
3017
|
+
finalizeUnresumableOrphan(orphan) {
|
|
3018
|
+
try {
|
|
3019
|
+
this.publishRunFinish(orphan.threadId, orphan.runId, 'cancelled', 'restart_lost_confirmation');
|
|
3020
|
+
void this.dbSnapshotStorage
|
|
3021
|
+
.markRunCancelled(orphan.threadId, orphan.runId)
|
|
3022
|
+
.catch((error) => {
|
|
3023
|
+
this.logger.warn('Failed to mark orphan snapshot as cancelled', {
|
|
3024
|
+
requestId: orphan.requestId,
|
|
3025
|
+
threadId: orphan.threadId,
|
|
3026
|
+
runId: orphan.runId,
|
|
3027
|
+
error: getErrorMessage(error),
|
|
3028
|
+
});
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
catch (error) {
|
|
3032
|
+
this.logger.warn('Failed to finalize orphaned confirmation snapshot', {
|
|
3033
|
+
requestId: orphan.requestId,
|
|
3034
|
+
error: getErrorMessage(error),
|
|
3035
|
+
});
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
async tryResumeFromOrphan(orphan, data) {
|
|
3039
|
+
const outcome = await this.rebuildSuspendedRunFromCheckpoint(orphan);
|
|
3040
|
+
switch (outcome.kind) {
|
|
3041
|
+
case 'ready':
|
|
3042
|
+
this.runState.suspendRun(orphan.threadId, outcome.state);
|
|
3043
|
+
return await this.resumeSuspendedRun(orphan.userId, orphan.requestId, data);
|
|
3044
|
+
case 'no-user':
|
|
3045
|
+
this.logger.warn('Cannot resume orphaned run: user no longer authorized', {
|
|
3046
|
+
requestId: orphan.requestId,
|
|
3047
|
+
userId: orphan.userId,
|
|
3048
|
+
});
|
|
3049
|
+
return false;
|
|
3050
|
+
case 'no-checkpoint':
|
|
3051
|
+
this.logger.warn('Cannot resume orphaned run: checkpoint missing or unavailable', {
|
|
3052
|
+
requestId: orphan.requestId,
|
|
3053
|
+
checkpointKey: orphan.checkpointKey,
|
|
3054
|
+
...(outcome.error ? { error: getErrorMessage(outcome.error) } : {}),
|
|
3055
|
+
});
|
|
3056
|
+
return false;
|
|
3057
|
+
case 'env-failure':
|
|
3058
|
+
this.logger.warn('Cannot resume orphaned run: failed to build execution environment', {
|
|
3059
|
+
requestId: orphan.requestId,
|
|
3060
|
+
threadId: orphan.threadId,
|
|
3061
|
+
error: getErrorMessage(outcome.error),
|
|
3062
|
+
});
|
|
3063
|
+
return false;
|
|
3064
|
+
case 'agent-failure':
|
|
3065
|
+
this.logger.warn('Cannot resume orphaned run: failed to build agent', {
|
|
3066
|
+
requestId: orphan.requestId,
|
|
3067
|
+
threadId: orphan.threadId,
|
|
3068
|
+
error: getErrorMessage(outcome.error),
|
|
3069
|
+
});
|
|
3070
|
+
return false;
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
async rebuildSuspendedRunFromCheckpoint(orphan) {
|
|
3074
|
+
const user = await this.revalidateActiveUser(orphan.userId);
|
|
3075
|
+
if (!user)
|
|
3076
|
+
return { kind: 'no-user' };
|
|
3077
|
+
try {
|
|
3078
|
+
const state = await this.checkpointStore.load(orphan.checkpointKey);
|
|
3079
|
+
if (!state)
|
|
3080
|
+
return { kind: 'no-checkpoint' };
|
|
3081
|
+
}
|
|
3082
|
+
catch (error) {
|
|
3083
|
+
return { kind: 'no-checkpoint', error };
|
|
3084
|
+
}
|
|
3085
|
+
const abortController = new AbortController();
|
|
3086
|
+
let environment;
|
|
3087
|
+
try {
|
|
3088
|
+
environment = await this.createExecutionEnvironment(user, orphan.threadId, orphan.runId, abortController.signal, orphan.messageGroupId ?? undefined, this.threadPushRef.get(orphan.threadId));
|
|
3089
|
+
}
|
|
3090
|
+
catch (error) {
|
|
3091
|
+
return { kind: 'env-failure', error };
|
|
3092
|
+
}
|
|
3093
|
+
const mcpServers = this.parseMcpServers(this.instanceAiConfig.mcpServers);
|
|
3094
|
+
let agent;
|
|
3095
|
+
try {
|
|
3096
|
+
agent = await (0, instance_ai_1.createInstanceAgent)({
|
|
3097
|
+
modelId: environment.modelId,
|
|
3098
|
+
context: environment.context,
|
|
3099
|
+
orchestrationContext: environment.orchestrationContext,
|
|
3100
|
+
mcpServers,
|
|
3101
|
+
mcpManager: this.mcpClientManager,
|
|
3102
|
+
memoryConfig: this.createAgentMemoryOptions(),
|
|
3103
|
+
memory: environment.memory,
|
|
3104
|
+
checkpointStore: this.checkpointStore,
|
|
3105
|
+
timeZone: this.runState.getTimeZone(orphan.threadId) ?? this.defaultTimeZone,
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
catch (error) {
|
|
3109
|
+
return { kind: 'agent-failure', error };
|
|
3110
|
+
}
|
|
3111
|
+
return {
|
|
3112
|
+
kind: 'ready',
|
|
3113
|
+
state: {
|
|
3114
|
+
runId: orphan.runId,
|
|
3115
|
+
agentRunId: orphan.checkpointKey,
|
|
3116
|
+
agent,
|
|
3117
|
+
threadId: orphan.threadId,
|
|
3118
|
+
user,
|
|
3119
|
+
toolCallId: orphan.toolCallId,
|
|
3120
|
+
requestId: orphan.requestId,
|
|
3121
|
+
abortController,
|
|
3122
|
+
messageGroupId: orphan.messageGroupId ?? undefined,
|
|
3123
|
+
createdAt: Date.now(),
|
|
3124
|
+
tracing: undefined,
|
|
3125
|
+
modelId: environment.modelId,
|
|
3126
|
+
checkpoint: orphan.checkpointTaskId
|
|
3127
|
+
? { isCheckpointFollowUp: true, checkpointTaskId: orphan.checkpointTaskId }
|
|
3128
|
+
: undefined,
|
|
3129
|
+
},
|
|
3130
|
+
};
|
|
2778
3131
|
}
|
|
2779
3132
|
async revalidateActiveUser(userId) {
|
|
2780
3133
|
try {
|
|
@@ -2818,6 +3171,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2818
3171
|
return false;
|
|
2819
3172
|
}
|
|
2820
3173
|
this.runState.activateSuspendedRun(threadId);
|
|
3174
|
+
void this.dropPendingConfirmation(requestId);
|
|
2821
3175
|
const credentialsPayload = data.nodeCredentials ?? data.credentials;
|
|
2822
3176
|
const resumeData = {
|
|
2823
3177
|
approved: data.approved,
|
|
@@ -2854,7 +3208,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2854
3208
|
: {}),
|
|
2855
3209
|
},
|
|
2856
3210
|
});
|
|
2857
|
-
|
|
3211
|
+
this.startProcessResumedStream(agent, resumeData, {
|
|
2858
3212
|
runId,
|
|
2859
3213
|
agentRunId,
|
|
2860
3214
|
threadId,
|
|
@@ -2921,6 +3275,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2921
3275
|
});
|
|
2922
3276
|
if (result.status === 'suspended') {
|
|
2923
3277
|
if (result.suspension) {
|
|
3278
|
+
const resumeMessageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
2924
3279
|
this.runState.suspendRun(opts.threadId, {
|
|
2925
3280
|
runId: opts.runId,
|
|
2926
3281
|
agentRunId: result.agentRunId,
|
|
@@ -2930,12 +3285,23 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2930
3285
|
toolCallId: result.suspension.toolCallId,
|
|
2931
3286
|
requestId: result.suspension.requestId,
|
|
2932
3287
|
abortController: opts.abortController,
|
|
2933
|
-
messageGroupId:
|
|
3288
|
+
messageGroupId: resumeMessageGroupId,
|
|
2934
3289
|
createdAt: Date.now(),
|
|
2935
3290
|
tracing: opts.tracing,
|
|
2936
3291
|
...(opts.modelId !== undefined ? { modelId: opts.modelId } : {}),
|
|
2937
3292
|
checkpoint: opts.checkpoint,
|
|
2938
3293
|
});
|
|
3294
|
+
void this.persistPendingConfirmation({
|
|
3295
|
+
requestId: result.suspension.requestId,
|
|
3296
|
+
threadId: opts.threadId,
|
|
3297
|
+
userId: opts.user.id,
|
|
3298
|
+
runId: opts.runId,
|
|
3299
|
+
messageGroupId: resumeMessageGroupId,
|
|
3300
|
+
kind: 'suspended',
|
|
3301
|
+
toolCallId: result.suspension.toolCallId,
|
|
3302
|
+
checkpointKey: result.agentRunId,
|
|
3303
|
+
checkpointTaskId: opts.checkpoint?.checkpointTaskId,
|
|
3304
|
+
});
|
|
2939
3305
|
}
|
|
2940
3306
|
const intermediateText = await (result.text ?? Promise.resolve(''));
|
|
2941
3307
|
if (intermediateText) {
|
|
@@ -3001,6 +3367,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3001
3367
|
};
|
|
3002
3368
|
return;
|
|
3003
3369
|
}
|
|
3370
|
+
if (result.status === 'cancelled' && this.shouldPreserveHitlOnShutdown(opts.runId)) {
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3004
3373
|
const outputText = await (result.text ?? Promise.resolve(''));
|
|
3005
3374
|
const messageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
3006
3375
|
this.evaluateTerminalResponse(opts.threadId, opts.runId, result.status, {
|
|
@@ -3036,6 +3405,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3036
3405
|
}
|
|
3037
3406
|
catch (error) {
|
|
3038
3407
|
if (opts.signal.aborted) {
|
|
3408
|
+
if (this.shouldPreserveHitlOnShutdown(opts.runId)) {
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3039
3411
|
const messageGroupId = this.traceContextsByRunId.get(opts.runId)?.messageGroupId;
|
|
3040
3412
|
const runTimeout = this.liveness.consumeRunTimeout(opts.runId);
|
|
3041
3413
|
const cancellationReason = runTimeout.timedOut
|
|
@@ -3388,6 +3760,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3388
3760
|
...(runTimeout ? { runTimeout } : {}),
|
|
3389
3761
|
}),
|
|
3390
3762
|
});
|
|
3763
|
+
void this.dropPendingConfirmation(suspended.requestId);
|
|
3391
3764
|
}
|
|
3392
3765
|
async reapAiTemporaryForThreadCleanup(threadId) {
|
|
3393
3766
|
let markedWorkflows;
|
|
@@ -3656,6 +4029,7 @@ exports.InstanceAiService = InstanceAiService = __decorate([
|
|
|
3656
4029
|
ai_service_1.AiService,
|
|
3657
4030
|
push_1.Push,
|
|
3658
4031
|
instance_ai_thread_repository_1.InstanceAiThreadRepository,
|
|
4032
|
+
instance_ai_pending_confirmation_repository_1.InstanceAiPendingConfirmationRepository,
|
|
3659
4033
|
url_service_1.UrlService,
|
|
3660
4034
|
db_snapshot_storage_1.DbSnapshotStorage,
|
|
3661
4035
|
db_iteration_log_storage_1.DbIterationLogStorage,
|