n8n 1.121.2 → 1.122.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/active-workflow-manager.js +35 -13
- package/dist/active-workflow-manager.js.map +1 -1
- package/dist/auth/auth.service.js +1 -0
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/commands/base-command.d.ts +2 -1
- package/dist/commands/base-command.js +1 -0
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/execute-batch.d.ts +2 -2
- package/dist/commands/start.js +2 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/webhook.js +1 -1
- package/dist/commands/webhook.js.map +1 -1
- package/dist/commands/worker.js +2 -1
- package/dist/commands/worker.js.map +1 -1
- package/dist/controllers/ai.controller.d.ts +1 -0
- package/dist/credentials/credentials-finder.service.d.ts +18 -3
- package/dist/credentials/credentials-finder.service.js +63 -7
- package/dist/credentials/credentials-finder.service.js.map +1 -1
- package/dist/credentials/credentials.controller.d.ts +4 -0
- package/dist/credentials/credentials.controller.js +9 -0
- package/dist/credentials/credentials.controller.js.map +1 -1
- package/dist/credentials/credentials.service.d.ts +25 -1
- package/dist/credentials/credentials.service.ee.d.ts +2 -0
- package/dist/credentials/credentials.service.js +100 -67
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-export.service.ee.js +2 -1
- package/dist/environments.ee/source-control/source-control-export.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-import.service.ee.js +21 -8
- package/dist/environments.ee/source-control/source-control-import.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/source-control-status.service.ee.js +2 -1
- package/dist/environments.ee/source-control/source-control-status.service.ee.js.map +1 -1
- package/dist/environments.ee/source-control/types/exportable-credential.d.ts +1 -0
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +2 -2
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
- package/dist/eventbus/message-event-bus/message-event-bus.js +1 -1
- package/dist/eventbus/message-event-bus/message-event-bus.js.map +1 -1
- package/dist/events/maps/relay.event-map.d.ts +9 -0
- package/dist/events/relays/telemetry.event-relay.d.ts +2 -0
- package/dist/events/relays/telemetry.event-relay.js +12 -0
- package/dist/events/relays/telemetry.event-relay.js.map +1 -1
- package/dist/execution-lifecycle/shared/shared-hook-functions.js +1 -0
- package/dist/execution-lifecycle/shared/shared-hook-functions.js.map +1 -1
- package/dist/executions/execution-data.service.d.ts +1 -1
- package/dist/executions/execution-data.service.js +3 -2
- package/dist/executions/execution-data.service.js.map +1 -1
- package/dist/executions/execution-recovery.service.js +1 -1
- package/dist/executions/execution-recovery.service.js.map +1 -1
- package/dist/executions/execution.service.js +1 -0
- package/dist/executions/execution.service.js.map +1 -1
- package/dist/executions/execution.utils.d.ts +2 -0
- package/dist/executions/execution.utils.js +7 -0
- package/dist/executions/execution.utils.js.map +1 -0
- package/dist/executions/pre-execution-checks/credentials-permission-checker.d.ts +4 -2
- package/dist/executions/pre-execution-checks/credentials-permission-checker.js +16 -2
- package/dist/executions/pre-execution-checks/credentials-permission-checker.js.map +1 -1
- package/dist/metrics/prometheus-metrics.service.d.ts +7 -2
- package/dist/metrics/prometheus-metrics.service.js +95 -2
- package/dist/metrics/prometheus-metrics.service.js.map +1 -1
- package/dist/metrics/types.d.ts +1 -1
- package/dist/middlewares/body-parser.js +3 -0
- package/dist/middlewares/body-parser.js.map +1 -1
- package/dist/middlewares/list-query/dtos/workflow.select.dto.js +1 -0
- package/dist/middlewares/list-query/dtos/workflow.select.dto.js.map +1 -1
- package/dist/modules/breaking-changes/breaking-changes.service.js +2 -2
- package/dist/modules/breaking-changes/breaking-changes.service.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/binary-data-storage.rule.d.ts +3 -1
- package/dist/modules/breaking-changes/rules/v2/binary-data-storage.rule.js +27 -19
- package/dist/modules/breaking-changes/rules/v2/binary-data-storage.rule.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-agent.service.js +1 -0
- package/dist/modules/chat-hub/chat-hub-agent.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-credentials.service.js +2 -2
- package/dist/modules/chat-hub/chat-hub-credentials.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-message.entity.d.ts +2 -0
- package/dist/modules/chat-hub/chat-hub-message.entity.js +4 -0
- package/dist/modules/chat-hub/chat-hub-message.entity.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-workflow.service.d.ts +4 -2
- package/dist/modules/chat-hub/chat-hub-workflow.service.js +147 -22
- package/dist/modules/chat-hub/chat-hub-workflow.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.attachment.service.d.ts +28 -0
- package/dist/modules/chat-hub/chat-hub.attachment.service.js +96 -0
- package/dist/modules/chat-hub/chat-hub.attachment.service.js.map +1 -0
- package/dist/modules/chat-hub/chat-hub.constants.d.ts +1 -0
- package/dist/modules/chat-hub/chat-hub.constants.js +46 -1
- package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.controller.d.ts +6 -3
- package/dist/modules/chat-hub/chat-hub.controller.js +59 -12
- package/dist/modules/chat-hub/chat-hub.controller.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.module.d.ts +13 -1
- package/dist/modules/chat-hub/chat-hub.module.js +3 -2
- package/dist/modules/chat-hub/chat-hub.module.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.service.d.ts +23 -8
- package/dist/modules/chat-hub/chat-hub.service.js +578 -102
- package/dist/modules/chat-hub/chat-hub.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.settings.controller.d.ts +39 -5
- package/dist/modules/chat-hub/chat-hub.settings.controller.js +28 -11
- package/dist/modules/chat-hub/chat-hub.settings.controller.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.settings.service.d.ts +5 -0
- package/dist/modules/chat-hub/chat-hub.settings.service.js +62 -3
- package/dist/modules/chat-hub/chat-hub.settings.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.types.d.ts +37 -1
- package/dist/modules/chat-hub/chat-hub.types.js +12 -0
- package/dist/modules/chat-hub/chat-hub.types.js.map +1 -1
- package/dist/modules/chat-hub/chat-message.repository.d.ts +2 -0
- package/dist/modules/chat-hub/chat-message.repository.js.map +1 -1
- package/dist/modules/chat-hub/chat-session.repository.d.ts +1 -1
- package/dist/modules/chat-hub/chat-session.repository.js +20 -5
- package/dist/modules/chat-hub/chat-session.repository.js.map +1 -1
- package/dist/modules/chat-hub/context-limits.js +11 -0
- package/dist/modules/chat-hub/context-limits.js.map +1 -1
- package/dist/modules/chat-hub/dto/chat-models-request.dto.d.ts +1 -1
- package/dist/modules/community-packages/community-node.command.js +1 -1
- package/dist/modules/community-packages/community-node.command.js.map +1 -1
- package/dist/modules/community-packages/community-packages.controller.js +3 -2
- package/dist/modules/community-packages/community-packages.controller.js.map +1 -1
- package/dist/modules/community-packages/community-packages.service.d.ts +1 -1
- package/dist/modules/community-packages/community-packages.service.js +9 -9
- package/dist/modules/community-packages/community-packages.service.js.map +1 -1
- package/dist/modules/data-table/csv-parser.service.d.ts +22 -0
- package/dist/modules/data-table/csv-parser.service.js +157 -0
- package/dist/modules/data-table/csv-parser.service.js.map +1 -0
- package/dist/modules/data-table/data-table-file-cleanup.service.d.ts +12 -0
- package/dist/modules/data-table/data-table-file-cleanup.service.js +81 -0
- package/dist/modules/data-table/data-table-file-cleanup.service.js.map +1 -0
- package/dist/modules/data-table/data-table-size-validator.service.d.ts +0 -1
- package/dist/modules/data-table/data-table-size-validator.service.js +2 -4
- package/dist/modules/data-table/data-table-size-validator.service.js.map +1 -1
- package/dist/modules/data-table/data-table-uploads.controller.d.ts +13 -0
- package/dist/modules/data-table/data-table-uploads.controller.js +68 -0
- package/dist/modules/data-table/data-table-uploads.controller.js.map +1 -0
- package/dist/modules/data-table/data-table.controller.d.ts +7 -0
- package/dist/modules/data-table/data-table.controller.js +28 -0
- package/dist/modules/data-table/data-table.controller.js.map +1 -1
- package/dist/modules/data-table/data-table.module.js +5 -0
- package/dist/modules/data-table/data-table.module.js.map +1 -1
- package/dist/modules/data-table/data-table.service.d.ts +14 -1
- package/dist/modules/data-table/data-table.service.js +115 -2
- package/dist/modules/data-table/data-table.service.js.map +1 -1
- package/dist/modules/data-table/errors/data-table-file-upload.error.d.ts +4 -0
- package/dist/modules/data-table/errors/data-table-file-upload.error.js +13 -0
- package/dist/modules/data-table/errors/data-table-file-upload.error.js.map +1 -0
- package/dist/modules/data-table/multer-upload-middleware.d.ts +15 -0
- package/dist/modules/data-table/multer-upload-middleware.js +98 -0
- package/dist/modules/data-table/multer-upload-middleware.js.map +1 -0
- package/dist/modules/data-table/types.d.ts +12 -0
- package/dist/modules/data-table/types.js +7 -0
- package/dist/modules/data-table/types.js.map +1 -0
- package/dist/modules/data-table/utils/size-utils.d.ts +2 -0
- package/dist/modules/data-table/utils/size-utils.js +19 -0
- package/dist/modules/data-table/utils/size-utils.js.map +1 -0
- package/dist/modules/insights/insights-collection.service.d.ts +2 -1
- package/dist/modules/insights/insights-collection.service.js +12 -1
- package/dist/modules/insights/insights-collection.service.js.map +1 -1
- package/dist/modules/insights/insights.module.js +4 -7
- package/dist/modules/insights/insights.module.js.map +1 -1
- package/dist/modules/insights/insights.service.d.ts +3 -16
- package/dist/modules/insights/insights.service.js +51 -25
- package/dist/modules/insights/insights.service.js.map +1 -1
- package/dist/modules/insights/insights.settings.d.ts +17 -0
- package/dist/modules/insights/insights.settings.js +44 -0
- package/dist/modules/insights/insights.settings.js.map +1 -0
- package/dist/modules/mcp/mcp-api-key.service.d.ts +3 -2
- package/dist/modules/mcp/mcp-api-key.service.js +22 -3
- package/dist/modules/mcp/mcp-api-key.service.js.map +1 -1
- package/dist/modules/mcp/mcp-oauth-token.service.d.ts +4 -3
- package/dist/modules/mcp/mcp-oauth-token.service.js +24 -6
- package/dist/modules/mcp/mcp-oauth-token.service.js.map +1 -1
- package/dist/modules/mcp/mcp-server-middleware.service.d.ts +4 -4
- package/dist/modules/mcp/mcp-server-middleware.service.js +43 -18
- package/dist/modules/mcp/mcp-server-middleware.service.js.map +1 -1
- package/dist/modules/mcp/mcp.errors.d.ts +7 -0
- package/dist/modules/mcp/mcp.errors.js +16 -1
- package/dist/modules/mcp/mcp.errors.js.map +1 -1
- package/dist/modules/mcp/mcp.settings.controller.js +1 -1
- package/dist/modules/mcp/mcp.settings.controller.js.map +1 -1
- package/dist/modules/mcp/mcp.types.d.ts +12 -0
- package/dist/modules/mcp/tools/execute-workflow.tool.js +2 -2
- package/dist/modules/mcp/tools/execute-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/get-workflow-details.tool.js +1 -1
- package/dist/modules/mcp/tools/get-workflow-details.tool.js.map +1 -1
- package/dist/modules/mcp/tools/search-workflows.tool.js +2 -1
- package/dist/modules/mcp/tools/search-workflows.tool.js.map +1 -1
- package/dist/modules/provisioning.ee/provisioning.service.ee.d.ts +3 -1
- package/dist/modules/provisioning.ee/provisioning.service.ee.js +14 -2
- package/dist/modules/provisioning.ee/provisioning.service.ee.js.map +1 -1
- package/dist/permissions.ee/check-access.js +13 -1
- package/dist/permissions.ee/check-access.js.map +1 -1
- package/dist/public-api/types.d.ts +3 -1
- package/dist/public-api/v1/handlers/workflows/workflows.handler.js +36 -14
- 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 -1
- package/dist/public-api/v1/handlers/workflows/workflows.service.js +6 -1
- package/dist/public-api/v1/handlers/workflows/workflows.service.js.map +1 -1
- package/dist/public-api/v1/openapi.yml +48 -3
- package/dist/requests.d.ts +1 -0
- package/dist/scaling/job-processor.d.ts +1 -0
- package/dist/scaling/job-processor.js +13 -2
- package/dist/scaling/job-processor.js.map +1 -1
- package/dist/scaling/scaling.service.js +13 -2
- package/dist/scaling/scaling.service.js.map +1 -1
- package/dist/scaling/scaling.types.d.ts +1 -0
- package/dist/security-audit/risk-reporters/credentials-risk-reporter.js +4 -3
- package/dist/security-audit/risk-reporters/credentials-risk-reporter.js.map +1 -1
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js +1 -1
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js.map +1 -1
- package/dist/security-audit/security-audit.service.js +1 -1
- package/dist/security-audit/security-audit.service.js.map +1 -1
- package/dist/services/ai-workflow-builder.service.d.ts +5 -1
- package/dist/services/ai-workflow-builder.service.js +12 -3
- package/dist/services/ai-workflow-builder.service.js.map +1 -1
- package/dist/services/import.service.js +2 -1
- package/dist/services/import.service.js.map +1 -1
- package/dist/services/role.service.js +8 -1
- package/dist/services/role.service.js.map +1 -1
- package/dist/task-runners/task-managers/data-request-response-builder.js +3 -2
- package/dist/task-runners/task-managers/data-request-response-builder.js.map +1 -1
- package/dist/task-runners/task-managers/data-request-response-stripper.js +3 -2
- package/dist/task-runners/task-managers/data-request-response-stripper.js.map +1 -1
- package/dist/webhooks/live-webhooks.js +11 -4
- package/dist/webhooks/live-webhooks.js.map +1 -1
- package/dist/webhooks/waiting-forms.d.ts +1 -1
- package/dist/webhooks/waiting-forms.js +2 -1
- package/dist/webhooks/waiting-forms.js.map +1 -1
- package/dist/webhooks/waiting-webhooks.d.ts +2 -1
- package/dist/webhooks/waiting-webhooks.js +2 -1
- package/dist/webhooks/waiting-webhooks.js.map +1 -1
- package/dist/workflow-execute-additional-data.js +13 -7
- package/dist/workflow-execute-additional-data.js.map +1 -1
- package/dist/workflow-helpers.d.ts +2 -0
- package/dist/workflow-helpers.js +10 -0
- package/dist/workflow-helpers.js.map +1 -1
- package/dist/workflow-runner.js +3 -3
- package/dist/workflow-runner.js.map +1 -1
- package/dist/workflows/workflow-execution.service.js +4 -3
- package/dist/workflows/workflow-execution.service.js.map +1 -1
- package/dist/workflows/workflow-finder.service.d.ts +3 -0
- package/dist/workflows/workflow-finder.service.js +1 -0
- package/dist/workflows/workflow-finder.service.js.map +1 -1
- package/dist/workflows/workflow-history/workflow-history-manager.js +1 -1
- package/dist/workflows/workflow-history/workflow-history-manager.js.map +1 -1
- package/dist/workflows/workflow-history/workflow-history.service.d.ts +5 -3
- package/dist/workflows/workflow-history/workflow-history.service.js +18 -4
- package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
- package/dist/workflows/workflow.request.d.ts +11 -0
- package/dist/workflows/workflow.service.d.ts +8 -1
- package/dist/workflows/workflow.service.ee.js +3 -3
- package/dist/workflows/workflow.service.ee.js.map +1 -1
- package/dist/workflows/workflow.service.js +145 -46
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.d.ts +74 -8
- package/dist/workflows/workflows.controller.js +65 -10
- package/dist/workflows/workflows.controller.js.map +1 -1
- package/package.json +18 -17
- package/dist/modules/chat-hub/dto/chat-message-request.dto.d.ts +0 -9
- package/dist/modules/chat-hub/dto/chat-message-request.dto.js +0 -12
- package/dist/modules/chat-hub/dto/chat-message-request.dto.js.map +0 -1
- package/dist/modules/chat-hub/dto/update-chat-settings.dto.d.ts +0 -8
- package/dist/modules/chat-hub/dto/update-chat-settings.dto.js +0 -11
- package/dist/modules/chat-hub/dto/update-chat-settings.dto.js.map +0 -1
|
@@ -15,13 +15,6 @@ const backend_common_1 = require("@n8n/backend-common");
|
|
|
15
15
|
const db_1 = require("@n8n/db");
|
|
16
16
|
const di_1 = require("@n8n/di");
|
|
17
17
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
18
|
-
const chat_hub_agent_service_1 = require("./chat-hub-agent.service");
|
|
19
|
-
const chat_hub_credentials_service_1 = require("./chat-hub-credentials.service");
|
|
20
|
-
const chat_hub_workflow_service_1 = require("./chat-hub-workflow.service");
|
|
21
|
-
const chat_hub_constants_1 = require("./chat-hub.constants");
|
|
22
|
-
const chat_message_repository_1 = require("./chat-message.repository");
|
|
23
|
-
const chat_session_repository_1 = require("./chat-session.repository");
|
|
24
|
-
const stream_capturer_1 = require("./stream-capturer");
|
|
25
18
|
const active_executions_1 = require("../../active-executions");
|
|
26
19
|
const credentials_finder_service_1 = require("../../credentials/credentials-finder.service");
|
|
27
20
|
const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
|
|
@@ -32,8 +25,18 @@ const workflow_execute_additional_data_1 = require("../../workflow-execute-addit
|
|
|
32
25
|
const workflow_execution_service_1 = require("../../workflows/workflow-execution.service");
|
|
33
26
|
const workflow_finder_service_1 = require("../../workflows/workflow-finder.service");
|
|
34
27
|
const workflow_service_1 = require("../../workflows/workflow.service");
|
|
28
|
+
const chat_hub_agent_service_1 = require("./chat-hub-agent.service");
|
|
29
|
+
const chat_hub_credentials_service_1 = require("./chat-hub-credentials.service");
|
|
30
|
+
const chat_hub_workflow_service_1 = require("./chat-hub-workflow.service");
|
|
31
|
+
const chat_hub_attachment_service_1 = require("./chat-hub.attachment.service");
|
|
32
|
+
const chat_hub_constants_1 = require("./chat-hub.constants");
|
|
33
|
+
const chat_hub_settings_service_1 = require("./chat-hub.settings.service");
|
|
34
|
+
const chat_hub_types_1 = require("./chat-hub.types");
|
|
35
|
+
const chat_message_repository_1 = require("./chat-message.repository");
|
|
36
|
+
const chat_session_repository_1 = require("./chat-session.repository");
|
|
37
|
+
const stream_capturer_1 = require("./stream-capturer");
|
|
35
38
|
let ChatHubService = class ChatHubService {
|
|
36
|
-
constructor(logger, executionService, nodeParametersService, executionRepository, workflowExecutionService, workflowService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, credentialsFinderService, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService) {
|
|
39
|
+
constructor(logger, executionService, nodeParametersService, executionRepository, workflowExecutionService, workflowService, workflowFinderService, workflowRepository, activeExecutions, sessionRepository, messageRepository, credentialsFinderService, chatHubAgentService, chatHubCredentialsService, chatHubWorkflowService, chatHubSettingsService, chatHubAttachmentService) {
|
|
37
40
|
this.logger = logger;
|
|
38
41
|
this.executionService = executionService;
|
|
39
42
|
this.nodeParametersService = nodeParametersService;
|
|
@@ -49,6 +52,8 @@ let ChatHubService = class ChatHubService {
|
|
|
49
52
|
this.chatHubAgentService = chatHubAgentService;
|
|
50
53
|
this.chatHubCredentialsService = chatHubCredentialsService;
|
|
51
54
|
this.chatHubWorkflowService = chatHubWorkflowService;
|
|
55
|
+
this.chatHubSettingsService = chatHubSettingsService;
|
|
56
|
+
this.chatHubAttachmentService = chatHubAttachmentService;
|
|
52
57
|
}
|
|
53
58
|
async getModels(user, credentialIds) {
|
|
54
59
|
const additionalData = await (0, workflow_execute_additional_data_1.getBase)({ userId: user.id });
|
|
@@ -97,6 +102,27 @@ let ChatHubService = class ChatHubService {
|
|
|
97
102
|
return await this.fetchAnthropicModels(credentials, additionalData);
|
|
98
103
|
case 'google':
|
|
99
104
|
return await this.fetchGoogleModels(credentials, additionalData);
|
|
105
|
+
case 'ollama':
|
|
106
|
+
return await this.fetchOllamaModels(credentials, additionalData);
|
|
107
|
+
case 'azureOpenAi':
|
|
108
|
+
case 'azureEntraId':
|
|
109
|
+
return this.fetchAzureOpenAiModels(credentials, additionalData);
|
|
110
|
+
case 'awsBedrock':
|
|
111
|
+
return await this.fetchAwsBedrockModels(credentials, additionalData);
|
|
112
|
+
case 'vercelAiGateway':
|
|
113
|
+
return await this.fetchVercelAiGatewayModels(credentials, additionalData);
|
|
114
|
+
case 'xAiGrok':
|
|
115
|
+
return await this.fetchXAiGrokModels(credentials, additionalData);
|
|
116
|
+
case 'groq':
|
|
117
|
+
return await this.fetchGroqModels(credentials, additionalData);
|
|
118
|
+
case 'openRouter':
|
|
119
|
+
return await this.fetchOpenRouterModels(credentials, additionalData);
|
|
120
|
+
case 'deepSeek':
|
|
121
|
+
return await this.fetchDeepSeekModels(credentials, additionalData);
|
|
122
|
+
case 'cohere':
|
|
123
|
+
return await this.fetchCohereModels(credentials, additionalData);
|
|
124
|
+
case 'mistralCloud':
|
|
125
|
+
return await this.fetchMistralCloudModels(credentials, additionalData);
|
|
100
126
|
case 'n8n':
|
|
101
127
|
return await this.fetchAgentWorkflowsAsModels(user);
|
|
102
128
|
case 'custom-agent':
|
|
@@ -115,6 +141,7 @@ let ChatHubService = class ChatHubService {
|
|
|
115
141
|
},
|
|
116
142
|
createdAt: null,
|
|
117
143
|
updatedAt: null,
|
|
144
|
+
allowFileUploads: true,
|
|
118
145
|
})),
|
|
119
146
|
};
|
|
120
147
|
}
|
|
@@ -130,6 +157,7 @@ let ChatHubService = class ChatHubService {
|
|
|
130
157
|
},
|
|
131
158
|
createdAt: null,
|
|
132
159
|
updatedAt: null,
|
|
160
|
+
allowFileUploads: true,
|
|
133
161
|
})),
|
|
134
162
|
};
|
|
135
163
|
}
|
|
@@ -174,7 +202,7 @@ let ChatHubService = class ChatHubService {
|
|
|
174
202
|
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.google, {}, credentials);
|
|
175
203
|
return {
|
|
176
204
|
models: results.map((result) => ({
|
|
177
|
-
name:
|
|
205
|
+
name: result.name,
|
|
178
206
|
description: result.description ?? null,
|
|
179
207
|
model: {
|
|
180
208
|
provider: 'google',
|
|
@@ -182,6 +210,463 @@ let ChatHubService = class ChatHubService {
|
|
|
182
210
|
},
|
|
183
211
|
createdAt: null,
|
|
184
212
|
updatedAt: null,
|
|
213
|
+
allowFileUploads: true,
|
|
214
|
+
})),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async fetchOllamaModels(credentials, additionalData) {
|
|
218
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
219
|
+
routing: {
|
|
220
|
+
request: {
|
|
221
|
+
method: 'GET',
|
|
222
|
+
url: '/api/tags',
|
|
223
|
+
},
|
|
224
|
+
output: {
|
|
225
|
+
postReceive: [
|
|
226
|
+
{
|
|
227
|
+
type: 'rootProperty',
|
|
228
|
+
properties: {
|
|
229
|
+
property: 'models',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
type: 'setKeyValue',
|
|
234
|
+
properties: {
|
|
235
|
+
name: '={{$responseItem.name}}',
|
|
236
|
+
value: '={{$responseItem.name}}',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
type: 'sort',
|
|
241
|
+
properties: {
|
|
242
|
+
key: 'name',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.ollama, {}, credentials);
|
|
249
|
+
return {
|
|
250
|
+
models: results.map((result) => ({
|
|
251
|
+
name: result.name,
|
|
252
|
+
description: result.description ?? null,
|
|
253
|
+
model: {
|
|
254
|
+
provider: 'ollama',
|
|
255
|
+
model: String(result.value),
|
|
256
|
+
},
|
|
257
|
+
createdAt: null,
|
|
258
|
+
updatedAt: null,
|
|
259
|
+
allowFileUploads: true,
|
|
260
|
+
})),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
fetchAzureOpenAiModels(_credentials, _additionalData) {
|
|
264
|
+
return {
|
|
265
|
+
models: [],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async fetchAwsBedrockModels(credentials, additionalData) {
|
|
269
|
+
const foundationModelsRequest = this.nodeParametersService.getOptionsViaLoadOptions({
|
|
270
|
+
routing: {
|
|
271
|
+
request: {
|
|
272
|
+
method: 'GET',
|
|
273
|
+
url: '/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND',
|
|
274
|
+
},
|
|
275
|
+
output: {
|
|
276
|
+
postReceive: [
|
|
277
|
+
{
|
|
278
|
+
type: 'rootProperty',
|
|
279
|
+
properties: {
|
|
280
|
+
property: 'modelSummaries',
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: 'setKeyValue',
|
|
285
|
+
properties: {
|
|
286
|
+
name: '={{$responseItem.modelName}}',
|
|
287
|
+
description: '={{$responseItem.modelArn}}',
|
|
288
|
+
value: '={{$responseItem.modelId}}',
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
type: 'sort',
|
|
293
|
+
properties: {
|
|
294
|
+
key: 'name',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.awsBedrock, {}, credentials);
|
|
301
|
+
const inferenceProfileModelsRequest = this.nodeParametersService.getOptionsViaLoadOptions({
|
|
302
|
+
routing: {
|
|
303
|
+
request: {
|
|
304
|
+
method: 'GET',
|
|
305
|
+
url: '/inference-profiles?maxResults=1000',
|
|
306
|
+
},
|
|
307
|
+
output: {
|
|
308
|
+
postReceive: [
|
|
309
|
+
{
|
|
310
|
+
type: 'rootProperty',
|
|
311
|
+
properties: {
|
|
312
|
+
property: 'inferenceProfileSummaries',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
type: 'setKeyValue',
|
|
317
|
+
properties: {
|
|
318
|
+
name: '={{$responseItem.inferenceProfileName}}',
|
|
319
|
+
description: '={{$responseItem.description || $responseItem.inferenceProfileArn}}',
|
|
320
|
+
value: '={{$responseItem.inferenceProfileId}}',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
type: 'sort',
|
|
325
|
+
properties: {
|
|
326
|
+
key: 'name',
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.awsBedrock, {}, credentials);
|
|
333
|
+
const [foundationModels, inferenceProfileModels] = await Promise.all([
|
|
334
|
+
foundationModelsRequest,
|
|
335
|
+
inferenceProfileModelsRequest,
|
|
336
|
+
]);
|
|
337
|
+
return {
|
|
338
|
+
models: foundationModels.concat(inferenceProfileModels).map((result) => ({
|
|
339
|
+
name: result.name,
|
|
340
|
+
description: result.description ?? String(result.value),
|
|
341
|
+
model: {
|
|
342
|
+
provider: 'awsBedrock',
|
|
343
|
+
model: String(result.value),
|
|
344
|
+
},
|
|
345
|
+
createdAt: null,
|
|
346
|
+
updatedAt: null,
|
|
347
|
+
allowFileUploads: true,
|
|
348
|
+
})),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
async fetchMistralCloudModels(credentials, additionalData) {
|
|
352
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
353
|
+
routing: {
|
|
354
|
+
request: {
|
|
355
|
+
method: 'GET',
|
|
356
|
+
url: '/models',
|
|
357
|
+
},
|
|
358
|
+
output: {
|
|
359
|
+
postReceive: [
|
|
360
|
+
{
|
|
361
|
+
type: 'rootProperty',
|
|
362
|
+
properties: {
|
|
363
|
+
property: 'data',
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
type: 'filter',
|
|
368
|
+
properties: {
|
|
369
|
+
pass: "={{ !$responseItem.id.includes('embed') }}",
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
type: 'setKeyValue',
|
|
374
|
+
properties: {
|
|
375
|
+
name: '={{ $responseItem.id }}',
|
|
376
|
+
value: '={{ $responseItem.id }}',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
type: 'sort',
|
|
381
|
+
properties: {
|
|
382
|
+
key: 'name',
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.mistralCloud, {}, credentials);
|
|
389
|
+
return {
|
|
390
|
+
models: results.map((result) => ({
|
|
391
|
+
name: result.name,
|
|
392
|
+
description: result.description ?? String(result.value),
|
|
393
|
+
model: {
|
|
394
|
+
provider: 'mistralCloud',
|
|
395
|
+
model: String(result.value),
|
|
396
|
+
},
|
|
397
|
+
createdAt: null,
|
|
398
|
+
updatedAt: null,
|
|
399
|
+
})),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
async fetchCohereModels(credentials, additionalData) {
|
|
403
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
404
|
+
routing: {
|
|
405
|
+
request: {
|
|
406
|
+
method: 'GET',
|
|
407
|
+
url: '/v1/models?page_size=100&endpoint=chat',
|
|
408
|
+
},
|
|
409
|
+
output: {
|
|
410
|
+
postReceive: [
|
|
411
|
+
{
|
|
412
|
+
type: 'rootProperty',
|
|
413
|
+
properties: {
|
|
414
|
+
property: 'models',
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
type: 'setKeyValue',
|
|
419
|
+
properties: {
|
|
420
|
+
name: '={{$responseItem.name}}',
|
|
421
|
+
value: '={{$responseItem.name}}',
|
|
422
|
+
description: '={{$responseItem.description}}',
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
type: 'sort',
|
|
427
|
+
properties: {
|
|
428
|
+
key: 'name',
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.cohere, {}, credentials);
|
|
435
|
+
return {
|
|
436
|
+
models: results.map((result) => ({
|
|
437
|
+
name: result.name,
|
|
438
|
+
description: result.description ?? null,
|
|
439
|
+
model: {
|
|
440
|
+
provider: 'cohere',
|
|
441
|
+
model: String(result.value),
|
|
442
|
+
},
|
|
443
|
+
createdAt: null,
|
|
444
|
+
updatedAt: null,
|
|
445
|
+
})),
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
async fetchDeepSeekModels(credentials, additionalData) {
|
|
449
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
450
|
+
routing: {
|
|
451
|
+
request: {
|
|
452
|
+
method: 'GET',
|
|
453
|
+
url: '/models',
|
|
454
|
+
},
|
|
455
|
+
output: {
|
|
456
|
+
postReceive: [
|
|
457
|
+
{
|
|
458
|
+
type: 'rootProperty',
|
|
459
|
+
properties: {
|
|
460
|
+
property: 'data',
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
type: 'setKeyValue',
|
|
465
|
+
properties: {
|
|
466
|
+
name: '={{$responseItem.id}}',
|
|
467
|
+
value: '={{$responseItem.id}}',
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
type: 'sort',
|
|
472
|
+
properties: {
|
|
473
|
+
key: 'name',
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.deepSeek, {}, credentials);
|
|
480
|
+
return {
|
|
481
|
+
models: results.map((result) => ({
|
|
482
|
+
name: result.name,
|
|
483
|
+
description: result.description ?? String(result.value),
|
|
484
|
+
model: {
|
|
485
|
+
provider: 'deepSeek',
|
|
486
|
+
model: String(result.value),
|
|
487
|
+
},
|
|
488
|
+
createdAt: null,
|
|
489
|
+
updatedAt: null,
|
|
490
|
+
})),
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
async fetchOpenRouterModels(credentials, additionalData) {
|
|
494
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
495
|
+
routing: {
|
|
496
|
+
request: {
|
|
497
|
+
method: 'GET',
|
|
498
|
+
url: '/models',
|
|
499
|
+
},
|
|
500
|
+
output: {
|
|
501
|
+
postReceive: [
|
|
502
|
+
{
|
|
503
|
+
type: 'rootProperty',
|
|
504
|
+
properties: {
|
|
505
|
+
property: 'data',
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
type: 'setKeyValue',
|
|
510
|
+
properties: {
|
|
511
|
+
name: '={{$responseItem.id}}',
|
|
512
|
+
value: '={{$responseItem.id}}',
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
type: 'sort',
|
|
517
|
+
properties: {
|
|
518
|
+
key: 'name',
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.openRouter, {}, credentials);
|
|
525
|
+
return {
|
|
526
|
+
models: results.map((result) => ({
|
|
527
|
+
name: result.name,
|
|
528
|
+
description: result.description ?? null,
|
|
529
|
+
model: {
|
|
530
|
+
provider: 'openRouter',
|
|
531
|
+
model: String(result.value),
|
|
532
|
+
},
|
|
533
|
+
createdAt: null,
|
|
534
|
+
updatedAt: null,
|
|
535
|
+
})),
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
async fetchGroqModels(credentials, additionalData) {
|
|
539
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
540
|
+
routing: {
|
|
541
|
+
request: {
|
|
542
|
+
method: 'GET',
|
|
543
|
+
url: '/models',
|
|
544
|
+
},
|
|
545
|
+
output: {
|
|
546
|
+
postReceive: [
|
|
547
|
+
{
|
|
548
|
+
type: 'rootProperty',
|
|
549
|
+
properties: {
|
|
550
|
+
property: 'data',
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
type: 'filter',
|
|
555
|
+
properties: {
|
|
556
|
+
pass: '={{ $responseItem.active === true && $responseItem.object === "model" }}',
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
type: 'setKeyValue',
|
|
561
|
+
properties: {
|
|
562
|
+
name: '={{$responseItem.id}}',
|
|
563
|
+
value: '={{$responseItem.id}}',
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
],
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.groq, {}, credentials);
|
|
570
|
+
return {
|
|
571
|
+
models: results.map((result) => ({
|
|
572
|
+
name: result.name,
|
|
573
|
+
description: result.description ?? null,
|
|
574
|
+
model: {
|
|
575
|
+
provider: 'groq',
|
|
576
|
+
model: String(result.value),
|
|
577
|
+
},
|
|
578
|
+
createdAt: null,
|
|
579
|
+
updatedAt: null,
|
|
580
|
+
})),
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async fetchXAiGrokModels(credentials, additionalData) {
|
|
584
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
585
|
+
routing: {
|
|
586
|
+
request: {
|
|
587
|
+
method: 'GET',
|
|
588
|
+
url: '/models',
|
|
589
|
+
},
|
|
590
|
+
output: {
|
|
591
|
+
postReceive: [
|
|
592
|
+
{
|
|
593
|
+
type: 'rootProperty',
|
|
594
|
+
properties: {
|
|
595
|
+
property: 'data',
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
type: 'setKeyValue',
|
|
600
|
+
properties: {
|
|
601
|
+
name: '={{$responseItem.id}}',
|
|
602
|
+
value: '={{$responseItem.id}}',
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
type: 'sort',
|
|
607
|
+
properties: {
|
|
608
|
+
key: 'name',
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
],
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.xAiGrok, {}, credentials);
|
|
615
|
+
return {
|
|
616
|
+
models: results.map((result) => ({
|
|
617
|
+
name: result.name,
|
|
618
|
+
description: result.description ?? null,
|
|
619
|
+
model: {
|
|
620
|
+
provider: 'xAiGrok',
|
|
621
|
+
model: String(result.value),
|
|
622
|
+
},
|
|
623
|
+
createdAt: null,
|
|
624
|
+
updatedAt: null,
|
|
625
|
+
})),
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
async fetchVercelAiGatewayModels(credentials, additionalData) {
|
|
629
|
+
const results = await this.nodeParametersService.getOptionsViaLoadOptions({
|
|
630
|
+
routing: {
|
|
631
|
+
request: {
|
|
632
|
+
method: 'GET',
|
|
633
|
+
url: '/models',
|
|
634
|
+
},
|
|
635
|
+
output: {
|
|
636
|
+
postReceive: [
|
|
637
|
+
{
|
|
638
|
+
type: 'rootProperty',
|
|
639
|
+
properties: {
|
|
640
|
+
property: 'data',
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
type: 'setKeyValue',
|
|
645
|
+
properties: {
|
|
646
|
+
name: '={{$responseItem.id}}',
|
|
647
|
+
value: '={{$responseItem.id}}',
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
type: 'sort',
|
|
652
|
+
properties: {
|
|
653
|
+
key: 'name',
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
],
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
}, additionalData, chat_hub_constants_1.PROVIDER_NODE_TYPE_MAP.vercelAiGateway, {}, credentials);
|
|
660
|
+
return {
|
|
661
|
+
models: results.map((result) => ({
|
|
662
|
+
name: result.name,
|
|
663
|
+
description: result.description ?? String(result.value),
|
|
664
|
+
model: {
|
|
665
|
+
provider: 'vercelAiGateway',
|
|
666
|
+
model: String(result.value),
|
|
667
|
+
},
|
|
668
|
+
createdAt: null,
|
|
669
|
+
updatedAt: null,
|
|
185
670
|
})),
|
|
186
671
|
};
|
|
187
672
|
}
|
|
@@ -191,32 +676,27 @@ let ChatHubService = class ChatHubService {
|
|
|
191
676
|
return {
|
|
192
677
|
models: workflows
|
|
193
678
|
.filter((workflow) => workflow.scopes.includes('workflow:read'))
|
|
194
|
-
.filter((workflow) => workflow.
|
|
679
|
+
.filter((workflow) => !!workflow.activeVersionId)
|
|
195
680
|
.flatMap((workflow) => {
|
|
196
681
|
const chatTrigger = workflow.nodes?.find((node) => node.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE);
|
|
197
682
|
if (!chatTrigger) {
|
|
198
683
|
return [];
|
|
199
684
|
}
|
|
200
|
-
|
|
685
|
+
const chatTriggerParams = chat_hub_types_1.validChatTriggerParamsShape.safeParse(chatTrigger.parameters).data;
|
|
686
|
+
if (!chatTriggerParams) {
|
|
201
687
|
return [];
|
|
202
688
|
}
|
|
203
|
-
const name = typeof chatTrigger.parameters.agentName === 'string' &&
|
|
204
|
-
chatTrigger.parameters.agentName.length > 0
|
|
205
|
-
? chatTrigger.parameters.agentName
|
|
206
|
-
: workflow.name;
|
|
207
689
|
return [
|
|
208
690
|
{
|
|
209
|
-
name: name ?? 'Unknown Agent',
|
|
210
|
-
description:
|
|
211
|
-
chatTrigger.parameters.agentDescription.length > 0
|
|
212
|
-
? chatTrigger.parameters.agentDescription
|
|
213
|
-
: null,
|
|
691
|
+
name: chatTriggerParams.agentName ?? workflow.name ?? 'Unknown Agent',
|
|
692
|
+
description: chatTriggerParams.agentDescription ?? null,
|
|
214
693
|
model: {
|
|
215
694
|
provider: 'n8n',
|
|
216
695
|
workflowId: workflow.id,
|
|
217
696
|
},
|
|
218
697
|
createdAt: workflow.createdAt ? workflow.createdAt.toISOString() : null,
|
|
219
698
|
updatedAt: workflow.updatedAt ? workflow.updatedAt.toISOString() : null,
|
|
699
|
+
allowFileUploads: chatTriggerParams.options?.allowFileUploads ?? false,
|
|
220
700
|
},
|
|
221
701
|
];
|
|
222
702
|
}),
|
|
@@ -255,23 +735,28 @@ let ChatHubService = class ChatHubService {
|
|
|
255
735
|
return credentials[api_types_1.PROVIDER_CREDENTIAL_TYPE_MAP[provider]]?.id ?? null;
|
|
256
736
|
}
|
|
257
737
|
async sendHumanMessage(res, user, payload) {
|
|
258
|
-
const { sessionId, messageId, message, model, credentials, previousMessageId, tools } = payload;
|
|
738
|
+
const { sessionId, messageId, message, model, credentials, previousMessageId, tools, attachments, } = payload;
|
|
259
739
|
const credentialId = this.getModelCredential(model, credentials);
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return await this.
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
740
|
+
const processedAttachments = await this.chatHubAttachmentService.store(sessionId, messageId, attachments);
|
|
741
|
+
let executionData;
|
|
742
|
+
let workflowData;
|
|
743
|
+
try {
|
|
744
|
+
const result = await this.messageRepository.manager.transaction(async (trx) => {
|
|
745
|
+
let session = await this.getChatSession(user, sessionId, trx);
|
|
746
|
+
session ??= await this.createChatSession(user, sessionId, model, credentialId, tools, trx);
|
|
747
|
+
await this.ensurePreviousMessage(previousMessageId, sessionId, trx);
|
|
748
|
+
const messages = Object.fromEntries((session.messages ?? []).map((m) => [m.id, m]));
|
|
749
|
+
const history = this.buildMessageHistory(messages, previousMessageId);
|
|
750
|
+
await this.saveHumanMessage(payload, processedAttachments, user, previousMessageId, model, undefined, trx);
|
|
751
|
+
return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, processedAttachments, trx);
|
|
752
|
+
});
|
|
753
|
+
executionData = result.executionData;
|
|
754
|
+
workflowData = result.workflowData;
|
|
755
|
+
}
|
|
756
|
+
catch (error) {
|
|
757
|
+
await this.chatHubAttachmentService.deleteAttachments(processedAttachments);
|
|
758
|
+
throw error;
|
|
759
|
+
}
|
|
275
760
|
await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, messageId, model);
|
|
276
761
|
if (previousMessageId === null) {
|
|
277
762
|
await this.generateSessionTitle(user, sessionId, message, credentials, model).catch((error) => {
|
|
@@ -287,9 +772,6 @@ let ChatHubService = class ChatHubService {
|
|
|
287
772
|
throw new not_found_error_1.NotFoundError('Chat session not found');
|
|
288
773
|
}
|
|
289
774
|
const messageToEdit = await this.getChatMessage(session.id, editId, [], trx);
|
|
290
|
-
if (!['ai', 'human'].includes(messageToEdit.type)) {
|
|
291
|
-
throw new bad_request_error_1.BadRequestError('Only human and AI messages can be edited');
|
|
292
|
-
}
|
|
293
775
|
if (messageToEdit.type === 'ai') {
|
|
294
776
|
await this.messageRepository.updateChatMessage(editId, { content: payload.message }, trx);
|
|
295
777
|
return null;
|
|
@@ -298,16 +780,11 @@ let ChatHubService = class ChatHubService {
|
|
|
298
780
|
const messages = Object.fromEntries((session.messages ?? []).map((m) => [m.id, m]));
|
|
299
781
|
const history = this.buildMessageHistory(messages, messageToEdit.previousMessageId);
|
|
300
782
|
const revisionOfMessageId = messageToEdit.revisionOfMessageId ?? messageToEdit.id;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
if (model.provider === 'custom-agent') {
|
|
306
|
-
return await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, trx);
|
|
307
|
-
}
|
|
308
|
-
return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, undefined, session.tools, trx);
|
|
783
|
+
const attachments = messageToEdit.attachments ?? [];
|
|
784
|
+
await this.saveHumanMessage(payload, attachments, user, messageToEdit.previousMessageId, model, revisionOfMessageId, trx);
|
|
785
|
+
return await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, trx);
|
|
309
786
|
}
|
|
310
|
-
|
|
787
|
+
throw new bad_request_error_1.BadRequestError('Only human and AI messages can be edited');
|
|
311
788
|
});
|
|
312
789
|
if (!workflow) {
|
|
313
790
|
return;
|
|
@@ -317,7 +794,6 @@ let ChatHubService = class ChatHubService {
|
|
|
317
794
|
}
|
|
318
795
|
async regenerateAIMessage(res, user, payload) {
|
|
319
796
|
const { sessionId, retryId, model, credentials } = payload;
|
|
320
|
-
const { provider } = model;
|
|
321
797
|
const { workflow: { workflowData, executionData }, retryOfMessageId, previousMessageId, } = await this.messageRepository.manager.transaction(async (trx) => {
|
|
322
798
|
const session = await this.getChatSession(user, sessionId, trx);
|
|
323
799
|
if (!session) {
|
|
@@ -339,16 +815,8 @@ let ChatHubService = class ChatHubService {
|
|
|
339
815
|
}
|
|
340
816
|
const retryOfMessageId = messageToRetry.retryOfMessageId ?? messageToRetry.id;
|
|
341
817
|
const message = lastHumanMessage ? lastHumanMessage.content : '';
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
workflow = await this.prepareCustomAgentWorkflow(user, sessionId, model.workflowId, message);
|
|
345
|
-
}
|
|
346
|
-
else if (provider === 'custom-agent') {
|
|
347
|
-
workflow = await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, trx);
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
workflow = await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, undefined, session.tools, trx);
|
|
351
|
-
}
|
|
818
|
+
const attachments = lastHumanMessage.attachments ?? [];
|
|
819
|
+
const workflow = await this.prepareReplyWorkflow(user, sessionId, credentials, model, history, message, session.tools, attachments, trx);
|
|
352
820
|
return {
|
|
353
821
|
workflow,
|
|
354
822
|
previousMessageId: lastHumanMessage.id,
|
|
@@ -357,11 +825,21 @@ let ChatHubService = class ChatHubService {
|
|
|
357
825
|
});
|
|
358
826
|
await this.executeChatWorkflowWithCleanup(res, user, workflowData, executionData, sessionId, previousMessageId, model, retryOfMessageId);
|
|
359
827
|
}
|
|
360
|
-
async
|
|
828
|
+
async prepareReplyWorkflow(user, sessionId, credentials, model, history, message, tools, attachments, trx) {
|
|
829
|
+
if (model.provider === 'n8n') {
|
|
830
|
+
return await this.prepareCustomAgentWorkflow(user, sessionId, model.workflowId, message, attachments);
|
|
831
|
+
}
|
|
832
|
+
if (model.provider === 'custom-agent') {
|
|
833
|
+
return await this.prepareChatAgentWorkflow(model.agentId, user, sessionId, history, message, attachments, trx);
|
|
834
|
+
}
|
|
835
|
+
return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, undefined, tools, attachments, trx);
|
|
836
|
+
}
|
|
837
|
+
async prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, trx) {
|
|
838
|
+
await this.chatHubSettingsService.ensureModelIsAllowed(model);
|
|
361
839
|
const credential = await this.chatHubCredentialsService.ensureCredentials(user, model.provider, credentials, trx);
|
|
362
|
-
return await this.chatHubWorkflowService.createChatWorkflow(user.id, sessionId, credential.projectId, history, message, credentials, model, systemMessage, tools, trx);
|
|
840
|
+
return await this.chatHubWorkflowService.createChatWorkflow(user.id, sessionId, credential.projectId, history, message, attachments, credentials, model, systemMessage, tools, trx);
|
|
363
841
|
}
|
|
364
|
-
async prepareChatAgentWorkflow(agentId, user, sessionId, history, message, trx) {
|
|
842
|
+
async prepareChatAgentWorkflow(agentId, user, sessionId, history, message, attachments, trx) {
|
|
365
843
|
const agent = await this.chatHubAgentService.getAgentById(agentId, user.id);
|
|
366
844
|
if (!agent) {
|
|
367
845
|
throw new bad_request_error_1.BadRequestError('Agent not found');
|
|
@@ -388,9 +866,9 @@ let ChatHubService = class ChatHubService {
|
|
|
388
866
|
},
|
|
389
867
|
};
|
|
390
868
|
const tools = [];
|
|
391
|
-
return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, trx);
|
|
869
|
+
return await this.prepareBaseChatWorkflow(user, sessionId, credentials, model, history, message, systemMessage, tools, attachments, trx);
|
|
392
870
|
}
|
|
393
|
-
async prepareCustomAgentWorkflow(user, sessionId, workflowId, message) {
|
|
871
|
+
async prepareCustomAgentWorkflow(user, sessionId, workflowId, message, attachments) {
|
|
394
872
|
const workflowEntity = await this.workflowFinderService.findWorkflowForUser(workflowId, user, ['workflow:read'], { includeTags: false, includeParentFolder: false });
|
|
395
873
|
if (!workflowEntity) {
|
|
396
874
|
throw new bad_request_error_1.BadRequestError('Workflow not found');
|
|
@@ -404,25 +882,7 @@ let ChatHubService = class ChatHubService {
|
|
|
404
882
|
if (chatResponseNodes.length > 0) {
|
|
405
883
|
throw new bad_request_error_1.BadRequestError('Respond to Chat nodes are not supported in custom agent workflows');
|
|
406
884
|
}
|
|
407
|
-
const nodeExecutionStack =
|
|
408
|
-
{
|
|
409
|
-
node: chatTriggerNode,
|
|
410
|
-
data: {
|
|
411
|
-
main: [
|
|
412
|
-
[
|
|
413
|
-
{
|
|
414
|
-
json: {
|
|
415
|
-
sessionId,
|
|
416
|
-
action: 'sendMessage',
|
|
417
|
-
chatInput: message,
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
],
|
|
421
|
-
],
|
|
422
|
-
},
|
|
423
|
-
source: null,
|
|
424
|
-
},
|
|
425
|
-
];
|
|
885
|
+
const nodeExecutionStack = this.chatHubWorkflowService.prepareExecutionData(chatTriggerNode, sessionId, message, attachments);
|
|
426
886
|
const executionData = (0, n8n_workflow_1.createRunExecutionData)({
|
|
427
887
|
executionData: {
|
|
428
888
|
nodeExecutionStack,
|
|
@@ -708,7 +1168,7 @@ let ChatHubService = class ChatHubService {
|
|
|
708
1168
|
const title = this.getAIOutput(execution, chat_hub_constants_1.NODE_NAMES.TITLE_GENERATOR_AGENT);
|
|
709
1169
|
return title ?? null;
|
|
710
1170
|
}
|
|
711
|
-
async saveHumanMessage(payload, user, previousMessageId, model, revisionOfMessageId, trx) {
|
|
1171
|
+
async saveHumanMessage(payload, attachments, user, previousMessageId, model, revisionOfMessageId, trx) {
|
|
712
1172
|
await this.messageRepository.createChatMessage({
|
|
713
1173
|
id: payload.messageId,
|
|
714
1174
|
sessionId: payload.sessionId,
|
|
@@ -718,6 +1178,7 @@ let ChatHubService = class ChatHubService {
|
|
|
718
1178
|
previousMessageId,
|
|
719
1179
|
revisionOfMessageId,
|
|
720
1180
|
name: user.firstName || 'User',
|
|
1181
|
+
attachments,
|
|
721
1182
|
...model,
|
|
722
1183
|
}, trx);
|
|
723
1184
|
}
|
|
@@ -783,23 +1244,30 @@ let ChatHubService = class ChatHubService {
|
|
|
783
1244
|
}
|
|
784
1245
|
return message;
|
|
785
1246
|
}
|
|
786
|
-
async getConversations(userId) {
|
|
787
|
-
const sessions = await this.sessionRepository.getManyByUserId(userId);
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1247
|
+
async getConversations(userId, limit, cursor) {
|
|
1248
|
+
const sessions = await this.sessionRepository.getManyByUserId(userId, limit + 1, cursor);
|
|
1249
|
+
const hasMore = sessions.length > limit;
|
|
1250
|
+
const data = hasMore ? sessions.slice(0, limit) : sessions;
|
|
1251
|
+
const nextCursor = hasMore ? data[data.length - 1].id : null;
|
|
1252
|
+
return {
|
|
1253
|
+
data: data.map((session) => ({
|
|
1254
|
+
id: session.id,
|
|
1255
|
+
title: session.title,
|
|
1256
|
+
ownerId: session.ownerId,
|
|
1257
|
+
lastMessageAt: session.lastMessageAt?.toISOString() ?? null,
|
|
1258
|
+
credentialId: session.credentialId,
|
|
1259
|
+
provider: session.provider,
|
|
1260
|
+
model: session.model,
|
|
1261
|
+
workflowId: session.workflowId,
|
|
1262
|
+
agentId: session.agentId,
|
|
1263
|
+
agentName: session.agentName,
|
|
1264
|
+
createdAt: session.createdAt.toISOString(),
|
|
1265
|
+
updatedAt: session.updatedAt.toISOString(),
|
|
1266
|
+
tools: session.tools,
|
|
1267
|
+
})),
|
|
1268
|
+
nextCursor,
|
|
1269
|
+
hasMore,
|
|
1270
|
+
};
|
|
803
1271
|
}
|
|
804
1272
|
async getConversation(userId, sessionId) {
|
|
805
1273
|
const session = await this.sessionRepository.getOneById(sessionId, userId);
|
|
@@ -846,6 +1314,10 @@ let ChatHubService = class ChatHubService {
|
|
|
846
1314
|
previousMessageId: message.previousMessageId,
|
|
847
1315
|
retryOfMessageId: message.retryOfMessageId,
|
|
848
1316
|
revisionOfMessageId: message.revisionOfMessageId,
|
|
1317
|
+
attachments: (message.attachments ?? []).map(({ fileName, mimeType }) => ({
|
|
1318
|
+
fileName,
|
|
1319
|
+
mimeType,
|
|
1320
|
+
})),
|
|
849
1321
|
};
|
|
850
1322
|
}
|
|
851
1323
|
buildMessageHistory(messages, lastMessageId) {
|
|
@@ -863,6 +1335,7 @@ let ChatHubService = class ChatHubService {
|
|
|
863
1335
|
return history;
|
|
864
1336
|
}
|
|
865
1337
|
async deleteAllSessions() {
|
|
1338
|
+
await this.chatHubAttachmentService.deleteAll();
|
|
866
1339
|
const result = await this.sessionRepository.deleteAll();
|
|
867
1340
|
return result;
|
|
868
1341
|
}
|
|
@@ -923,6 +1396,7 @@ let ChatHubService = class ChatHubService {
|
|
|
923
1396
|
if (!session) {
|
|
924
1397
|
throw new not_found_error_1.NotFoundError('Session not found');
|
|
925
1398
|
}
|
|
1399
|
+
await this.chatHubAttachmentService.deleteAllBySessionId(sessionId);
|
|
926
1400
|
await this.sessionRepository.deleteChatHubSession(sessionId);
|
|
927
1401
|
}
|
|
928
1402
|
};
|
|
@@ -943,6 +1417,8 @@ exports.ChatHubService = ChatHubService = __decorate([
|
|
|
943
1417
|
credentials_finder_service_1.CredentialsFinderService,
|
|
944
1418
|
chat_hub_agent_service_1.ChatHubAgentService,
|
|
945
1419
|
chat_hub_credentials_service_1.ChatHubCredentialsService,
|
|
946
|
-
chat_hub_workflow_service_1.ChatHubWorkflowService
|
|
1420
|
+
chat_hub_workflow_service_1.ChatHubWorkflowService,
|
|
1421
|
+
chat_hub_settings_service_1.ChatHubSettingsService,
|
|
1422
|
+
chat_hub_attachment_service_1.ChatHubAttachmentService])
|
|
947
1423
|
], ChatHubService);
|
|
948
1424
|
//# sourceMappingURL=chat-hub.service.js.map
|