n8n-atom-mcp 0.0.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/.env.example +220 -0
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/data/nodes.db +0 -0
- package/dist/community/community-node-fetcher.d.ts +118 -0
- package/dist/community/community-node-fetcher.d.ts.map +1 -0
- package/dist/community/community-node-fetcher.js +239 -0
- package/dist/community/community-node-fetcher.js.map +1 -0
- package/dist/community/community-node-service.d.ts +42 -0
- package/dist/community/community-node-service.d.ts.map +1 -0
- package/dist/community/community-node-service.js +210 -0
- package/dist/community/community-node-service.js.map +1 -0
- package/dist/community/documentation-batch-processor.d.ts +33 -0
- package/dist/community/documentation-batch-processor.d.ts.map +1 -0
- package/dist/community/documentation-batch-processor.js +156 -0
- package/dist/community/documentation-batch-processor.js.map +1 -0
- package/dist/community/documentation-generator.d.ts +65 -0
- package/dist/community/documentation-generator.d.ts.map +1 -0
- package/dist/community/documentation-generator.js +220 -0
- package/dist/community/documentation-generator.js.map +1 -0
- package/dist/community/index.d.ts +5 -0
- package/dist/community/index.d.ts.map +1 -0
- package/dist/community/index.js +14 -0
- package/dist/community/index.js.map +1 -0
- package/dist/config/n8n-api.d.ts +15 -0
- package/dist/config/n8n-api.d.ts.map +1 -0
- package/dist/config/n8n-api.js +53 -0
- package/dist/config/n8n-api.js.map +1 -0
- package/dist/constants/type-structures.d.ts +123 -0
- package/dist/constants/type-structures.d.ts.map +1 -0
- package/dist/constants/type-structures.js +654 -0
- package/dist/constants/type-structures.js.map +1 -0
- package/dist/database/database-adapter.d.ts +33 -0
- package/dist/database/database-adapter.d.ts.map +1 -0
- package/dist/database/database-adapter.js +420 -0
- package/dist/database/database-adapter.js.map +1 -0
- package/dist/database/node-repository.d.ts +152 -0
- package/dist/database/node-repository.d.ts.map +1 -0
- package/dist/database/node-repository.js +791 -0
- package/dist/database/node-repository.js.map +1 -0
- package/dist/errors/validation-service-error.d.ts +10 -0
- package/dist/errors/validation-service-error.d.ts.map +1 -0
- package/dist/errors/validation-service-error.js +26 -0
- package/dist/errors/validation-service-error.js.map +1 -0
- package/dist/http-server-single-session.d.ts +52 -0
- package/dist/http-server-single-session.d.ts.map +1 -0
- package/dist/http-server-single-session.js +1180 -0
- package/dist/http-server-single-session.js.map +1 -0
- package/dist/http-server.d.ts +9 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +481 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/node-loader.d.ts +11 -0
- package/dist/loaders/node-loader.d.ts.map +1 -0
- package/dist/loaders/node-loader.js +79 -0
- package/dist/loaders/node-loader.js.map +1 -0
- package/dist/mappers/docs-mapper.d.ts +7 -0
- package/dist/mappers/docs-mapper.d.ts.map +1 -0
- package/dist/mappers/docs-mapper.js +106 -0
- package/dist/mappers/docs-mapper.js.map +1 -0
- package/dist/mcp/handlers-n8n-manager.d.ts +58 -0
- package/dist/mcp/handlers-n8n-manager.d.ts.map +1 -0
- package/dist/mcp/handlers-n8n-manager.js +3299 -0
- package/dist/mcp/handlers-n8n-manager.js.map +1 -0
- package/dist/mcp/handlers-workflow-diff.d.ts +5 -0
- package/dist/mcp/handlers-workflow-diff.d.ts.map +1 -0
- package/dist/mcp/handlers-workflow-diff.js +461 -0
- package/dist/mcp/handlers-workflow-diff.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +228 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +82 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +3006 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/stdio-wrapper.d.ts +3 -0
- package/dist/mcp/stdio-wrapper.d.ts.map +1 -0
- package/dist/mcp/stdio-wrapper.js +81 -0
- package/dist/mcp/stdio-wrapper.js.map +1 -0
- package/dist/mcp/tool-docs/configuration/get-node.d.ts +3 -0
- package/dist/mcp/tool-docs/configuration/get-node.d.ts.map +1 -0
- package/dist/mcp/tool-docs/configuration/get-node.js +90 -0
- package/dist/mcp/tool-docs/configuration/get-node.js.map +1 -0
- package/dist/mcp/tool-docs/configuration/index.d.ts +2 -0
- package/dist/mcp/tool-docs/configuration/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/configuration/index.js +6 -0
- package/dist/mcp/tool-docs/configuration/index.js.map +1 -0
- package/dist/mcp/tool-docs/discovery/index.d.ts +2 -0
- package/dist/mcp/tool-docs/discovery/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/discovery/index.js +6 -0
- package/dist/mcp/tool-docs/discovery/index.js.map +1 -0
- package/dist/mcp/tool-docs/discovery/search-nodes.d.ts +3 -0
- package/dist/mcp/tool-docs/discovery/search-nodes.d.ts.map +1 -0
- package/dist/mcp/tool-docs/discovery/search-nodes.js +70 -0
- package/dist/mcp/tool-docs/discovery/search-nodes.js.map +1 -0
- package/dist/mcp/tool-docs/guides/ai-agents-guide.d.ts +3 -0
- package/dist/mcp/tool-docs/guides/ai-agents-guide.d.ts.map +1 -0
- package/dist/mcp/tool-docs/guides/ai-agents-guide.js +739 -0
- package/dist/mcp/tool-docs/guides/ai-agents-guide.js.map +1 -0
- package/dist/mcp/tool-docs/guides/index.d.ts +2 -0
- package/dist/mcp/tool-docs/guides/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/guides/index.js +6 -0
- package/dist/mcp/tool-docs/guides/index.js.map +1 -0
- package/dist/mcp/tool-docs/index.d.ts +4 -0
- package/dist/mcp/tool-docs/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/index.js +34 -0
- package/dist/mcp/tool-docs/index.js.map +1 -0
- package/dist/mcp/tool-docs/system/index.d.ts +3 -0
- package/dist/mcp/tool-docs/system/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/system/index.js +8 -0
- package/dist/mcp/tool-docs/system/index.js.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-diagnostic.d.ts +3 -0
- package/dist/mcp/tool-docs/system/n8n-diagnostic.d.ts.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-diagnostic.js +99 -0
- package/dist/mcp/tool-docs/system/n8n-diagnostic.js.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-health-check.d.ts +3 -0
- package/dist/mcp/tool-docs/system/n8n-health-check.d.ts.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-health-check.js +102 -0
- package/dist/mcp/tool-docs/system/n8n-health-check.js.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-list-available-tools.d.ts +3 -0
- package/dist/mcp/tool-docs/system/n8n-list-available-tools.d.ts.map +1 -0
- package/dist/mcp/tool-docs/system/n8n-list-available-tools.js +75 -0
- package/dist/mcp/tool-docs/system/n8n-list-available-tools.js.map +1 -0
- package/dist/mcp/tool-docs/system/tools-documentation.d.ts +3 -0
- package/dist/mcp/tool-docs/system/tools-documentation.d.ts.map +1 -0
- package/dist/mcp/tool-docs/system/tools-documentation.js +65 -0
- package/dist/mcp/tool-docs/system/tools-documentation.js.map +1 -0
- package/dist/mcp/tool-docs/templates/get-template.d.ts +3 -0
- package/dist/mcp/tool-docs/templates/get-template.d.ts.map +1 -0
- package/dist/mcp/tool-docs/templates/get-template.js +84 -0
- package/dist/mcp/tool-docs/templates/get-template.js.map +1 -0
- package/dist/mcp/tool-docs/templates/index.d.ts +3 -0
- package/dist/mcp/tool-docs/templates/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/templates/index.js +8 -0
- package/dist/mcp/tool-docs/templates/index.js.map +1 -0
- package/dist/mcp/tool-docs/templates/search-templates.d.ts +3 -0
- package/dist/mcp/tool-docs/templates/search-templates.d.ts.map +1 -0
- package/dist/mcp/tool-docs/templates/search-templates.js +143 -0
- package/dist/mcp/tool-docs/templates/search-templates.js.map +1 -0
- package/dist/mcp/tool-docs/types.d.ts +32 -0
- package/dist/mcp/tool-docs/types.d.ts.map +1 -0
- package/dist/mcp/tool-docs/types.js +3 -0
- package/dist/mcp/tool-docs/types.js.map +1 -0
- package/dist/mcp/tool-docs/validation/index.d.ts +3 -0
- package/dist/mcp/tool-docs/validation/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/validation/index.js +8 -0
- package/dist/mcp/tool-docs/validation/index.js.map +1 -0
- package/dist/mcp/tool-docs/validation/validate-node.d.ts +3 -0
- package/dist/mcp/tool-docs/validation/validate-node.d.ts.map +1 -0
- package/dist/mcp/tool-docs/validation/validate-node.js +82 -0
- package/dist/mcp/tool-docs/validation/validate-node.js.map +1 -0
- package/dist/mcp/tool-docs/validation/validate-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/validation/validate-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/validation/validate-workflow.js +86 -0
- package/dist/mcp/tool-docs/validation/validate-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/index.d.ts +13 -0
- package/dist/mcp/tool-docs/workflow_management/index.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/index.js +28 -0
- package/dist/mcp/tool-docs/workflow_management/index.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.js +162 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-autofix-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-create-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-create-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-create-workflow.js +102 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-create-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-delete-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-delete-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-delete-workflow.js +52 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-delete-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-deploy-template.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-deploy-template.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-deploy-template.js +73 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-deploy-template.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-executions.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-executions.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-executions.js +109 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-executions.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-get-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-get-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-get-workflow.js +68 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-get-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-list-workflows.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-list-workflows.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-list-workflows.js +57 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-list-workflows.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-test-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-test-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-test-workflow.js +140 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-test-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-full-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-full-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-full-workflow.js +61 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-full-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.js +420 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.js +73 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-validate-workflow.js.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-workflow-versions.d.ts +3 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-workflow-versions.d.ts.map +1 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-workflow-versions.js +170 -0
- package/dist/mcp/tool-docs/workflow_management/n8n-workflow-versions.js.map +1 -0
- package/dist/mcp/tools-documentation.d.ts +6 -0
- package/dist/mcp/tools-documentation.d.ts.map +1 -0
- package/dist/mcp/tools-documentation.js +682 -0
- package/dist/mcp/tools-documentation.js.map +1 -0
- package/dist/mcp/tools-file-operations.d.ts +154 -0
- package/dist/mcp/tools-file-operations.d.ts.map +1 -0
- package/dist/mcp/tools-file-operations.js +213 -0
- package/dist/mcp/tools-file-operations.js.map +1 -0
- package/dist/mcp/tools-n8n-friendly.d.ts +6 -0
- package/dist/mcp/tools-n8n-friendly.d.ts.map +1 -0
- package/dist/mcp/tools-n8n-friendly.js +89 -0
- package/dist/mcp/tools-n8n-friendly.js.map +1 -0
- package/dist/mcp/tools-n8n-manager.d.ts +3 -0
- package/dist/mcp/tools-n8n-manager.d.ts.map +1 -0
- package/dist/mcp/tools-n8n-manager.js +1320 -0
- package/dist/mcp/tools-n8n-manager.js.map +1 -0
- package/dist/mcp/tools.d.ts +3 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +424 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/workflow-examples.d.ts +76 -0
- package/dist/mcp/workflow-examples.d.ts.map +1 -0
- package/dist/mcp/workflow-examples.js +111 -0
- package/dist/mcp/workflow-examples.js.map +1 -0
- package/dist/mcp-engine.d.ts +36 -0
- package/dist/mcp-engine.d.ts.map +1 -0
- package/dist/mcp-engine.js +77 -0
- package/dist/mcp-engine.js.map +1 -0
- package/dist/mcp-tools-engine.d.ts +47 -0
- package/dist/mcp-tools-engine.d.ts.map +1 -0
- package/dist/mcp-tools-engine.js +89 -0
- package/dist/mcp-tools-engine.js.map +1 -0
- package/dist/n8n/MCPApi.credentials.d.ts +8 -0
- package/dist/n8n/MCPApi.credentials.d.ts.map +1 -0
- package/dist/n8n/MCPApi.credentials.js +53 -0
- package/dist/n8n/MCPApi.credentials.js.map +1 -0
- package/dist/n8n/MCPNode.node.d.ts +13 -0
- package/dist/n8n/MCPNode.node.d.ts.map +1 -0
- package/dist/n8n/MCPNode.node.js +260 -0
- package/dist/n8n/MCPNode.node.js.map +1 -0
- package/dist/parsers/node-parser.d.ts +38 -0
- package/dist/parsers/node-parser.d.ts.map +1 -0
- package/dist/parsers/node-parser.js +250 -0
- package/dist/parsers/node-parser.js.map +1 -0
- package/dist/parsers/property-extractor.d.ts +11 -0
- package/dist/parsers/property-extractor.d.ts.map +1 -0
- package/dist/parsers/property-extractor.js +172 -0
- package/dist/parsers/property-extractor.js.map +1 -0
- package/dist/parsers/simple-parser.d.ts +25 -0
- package/dist/parsers/simple-parser.d.ts.map +1 -0
- package/dist/parsers/simple-parser.js +212 -0
- package/dist/parsers/simple-parser.js.map +1 -0
- package/dist/scripts/debug-http-search.d.ts +3 -0
- package/dist/scripts/debug-http-search.d.ts.map +1 -0
- package/dist/scripts/debug-http-search.js +57 -0
- package/dist/scripts/debug-http-search.js.map +1 -0
- package/dist/scripts/extract-from-docker.d.ts +3 -0
- package/dist/scripts/extract-from-docker.d.ts.map +1 -0
- package/dist/scripts/extract-from-docker.js +210 -0
- package/dist/scripts/extract-from-docker.js.map +1 -0
- package/dist/scripts/fetch-community-nodes.d.ts +3 -0
- package/dist/scripts/fetch-community-nodes.d.ts.map +1 -0
- package/dist/scripts/fetch-community-nodes.js +114 -0
- package/dist/scripts/fetch-community-nodes.js.map +1 -0
- package/dist/scripts/fetch-templates-robust.d.ts +4 -0
- package/dist/scripts/fetch-templates-robust.d.ts.map +1 -0
- package/dist/scripts/fetch-templates-robust.js +132 -0
- package/dist/scripts/fetch-templates-robust.js.map +1 -0
- package/dist/scripts/fetch-templates.d.ts +4 -0
- package/dist/scripts/fetch-templates.d.ts.map +1 -0
- package/dist/scripts/fetch-templates.js +411 -0
- package/dist/scripts/fetch-templates.js.map +1 -0
- package/dist/scripts/generate-community-docs.d.ts +3 -0
- package/dist/scripts/generate-community-docs.d.ts.map +1 -0
- package/dist/scripts/generate-community-docs.js +183 -0
- package/dist/scripts/generate-community-docs.js.map +1 -0
- package/dist/scripts/migrate-readme-columns.d.ts +2 -0
- package/dist/scripts/migrate-readme-columns.d.ts.map +1 -0
- package/dist/scripts/migrate-readme-columns.js +62 -0
- package/dist/scripts/migrate-readme-columns.js.map +1 -0
- package/dist/scripts/rebuild-database.d.ts +4 -0
- package/dist/scripts/rebuild-database.d.ts.map +1 -0
- package/dist/scripts/rebuild-database.js +95 -0
- package/dist/scripts/rebuild-database.js.map +1 -0
- package/dist/scripts/rebuild-optimized.d.ts +3 -0
- package/dist/scripts/rebuild-optimized.d.ts.map +1 -0
- package/dist/scripts/rebuild-optimized.js +198 -0
- package/dist/scripts/rebuild-optimized.js.map +1 -0
- package/dist/scripts/rebuild.d.ts +3 -0
- package/dist/scripts/rebuild.d.ts.map +1 -0
- package/dist/scripts/rebuild.js +258 -0
- package/dist/scripts/rebuild.js.map +1 -0
- package/dist/scripts/sanitize-templates.d.ts +3 -0
- package/dist/scripts/sanitize-templates.d.ts.map +1 -0
- package/dist/scripts/sanitize-templates.js +88 -0
- package/dist/scripts/sanitize-templates.js.map +1 -0
- package/dist/scripts/seed-canonical-ai-examples.d.ts +4 -0
- package/dist/scripts/seed-canonical-ai-examples.d.ts.map +1 -0
- package/dist/scripts/seed-canonical-ai-examples.js +121 -0
- package/dist/scripts/seed-canonical-ai-examples.js.map +1 -0
- package/dist/scripts/test-autofix-documentation.d.ts +3 -0
- package/dist/scripts/test-autofix-documentation.d.ts.map +1 -0
- package/dist/scripts/test-autofix-documentation.js +103 -0
- package/dist/scripts/test-autofix-documentation.js.map +1 -0
- package/dist/scripts/test-autofix-workflow.d.ts +2 -0
- package/dist/scripts/test-autofix-workflow.d.ts.map +1 -0
- package/dist/scripts/test-autofix-workflow.js +223 -0
- package/dist/scripts/test-autofix-workflow.js.map +1 -0
- package/dist/scripts/test-execution-filtering.d.ts +3 -0
- package/dist/scripts/test-execution-filtering.d.ts.map +1 -0
- package/dist/scripts/test-execution-filtering.js +206 -0
- package/dist/scripts/test-execution-filtering.js.map +1 -0
- package/dist/scripts/test-node-suggestions.d.ts +3 -0
- package/dist/scripts/test-node-suggestions.d.ts.map +1 -0
- package/dist/scripts/test-node-suggestions.js +165 -0
- package/dist/scripts/test-node-suggestions.js.map +1 -0
- package/dist/scripts/test-protocol-negotiation.d.ts +3 -0
- package/dist/scripts/test-protocol-negotiation.d.ts.map +1 -0
- package/dist/scripts/test-protocol-negotiation.js +154 -0
- package/dist/scripts/test-protocol-negotiation.js.map +1 -0
- package/dist/scripts/test-summary.d.ts +3 -0
- package/dist/scripts/test-summary.d.ts.map +1 -0
- package/dist/scripts/test-summary.js +77 -0
- package/dist/scripts/test-summary.js.map +1 -0
- package/dist/scripts/test-telemetry-mutations-verbose.d.ts +2 -0
- package/dist/scripts/test-telemetry-mutations-verbose.d.ts.map +1 -0
- package/dist/scripts/test-telemetry-mutations-verbose.js +133 -0
- package/dist/scripts/test-telemetry-mutations-verbose.js.map +1 -0
- package/dist/scripts/test-telemetry-mutations.d.ts +2 -0
- package/dist/scripts/test-telemetry-mutations.d.ts.map +1 -0
- package/dist/scripts/test-telemetry-mutations.js +129 -0
- package/dist/scripts/test-telemetry-mutations.js.map +1 -0
- package/dist/scripts/test-webhook-autofix.d.ts +3 -0
- package/dist/scripts/test-webhook-autofix.d.ts.map +1 -0
- package/dist/scripts/test-webhook-autofix.js +117 -0
- package/dist/scripts/test-webhook-autofix.js.map +1 -0
- package/dist/scripts/validate.d.ts +3 -0
- package/dist/scripts/validate.d.ts.map +1 -0
- package/dist/scripts/validate.js +121 -0
- package/dist/scripts/validate.js.map +1 -0
- package/dist/scripts/validation-summary.d.ts +3 -0
- package/dist/scripts/validation-summary.d.ts.map +1 -0
- package/dist/scripts/validation-summary.js +135 -0
- package/dist/scripts/validation-summary.js.map +1 -0
- package/dist/services/ai-node-validator.d.ts +12 -0
- package/dist/services/ai-node-validator.d.ts.map +1 -0
- package/dist/services/ai-node-validator.js +429 -0
- package/dist/services/ai-node-validator.js.map +1 -0
- package/dist/services/ai-tool-validators.d.ts +58 -0
- package/dist/services/ai-tool-validators.d.ts.map +1 -0
- package/dist/services/ai-tool-validators.js +438 -0
- package/dist/services/ai-tool-validators.js.map +1 -0
- package/dist/services/breaking-change-detector.d.ts +38 -0
- package/dist/services/breaking-change-detector.d.ts.map +1 -0
- package/dist/services/breaking-change-detector.js +184 -0
- package/dist/services/breaking-change-detector.js.map +1 -0
- package/dist/services/breaking-changes-registry.d.ts +28 -0
- package/dist/services/breaking-changes-registry.d.ts.map +1 -0
- package/dist/services/breaking-changes-registry.js +200 -0
- package/dist/services/breaking-changes-registry.js.map +1 -0
- package/dist/services/community-package-service.d.ts +69 -0
- package/dist/services/community-package-service.d.ts.map +1 -0
- package/dist/services/community-package-service.js +202 -0
- package/dist/services/community-package-service.js.map +1 -0
- package/dist/services/confidence-scorer.d.ts +24 -0
- package/dist/services/confidence-scorer.d.ts.map +1 -0
- package/dist/services/confidence-scorer.js +139 -0
- package/dist/services/confidence-scorer.js.map +1 -0
- package/dist/services/config-validator.d.ts +49 -0
- package/dist/services/config-validator.d.ts.map +1 -0
- package/dist/services/config-validator.js +724 -0
- package/dist/services/config-validator.js.map +1 -0
- package/dist/services/enhanced-config-validator.d.ts +54 -0
- package/dist/services/enhanced-config-validator.d.ts.map +1 -0
- package/dist/services/enhanced-config-validator.js +789 -0
- package/dist/services/enhanced-config-validator.js.map +1 -0
- package/dist/services/error-execution-processor.d.ts +9 -0
- package/dist/services/error-execution-processor.d.ts.map +1 -0
- package/dist/services/error-execution-processor.js +380 -0
- package/dist/services/error-execution-processor.js.map +1 -0
- package/dist/services/example-generator.d.ts +14 -0
- package/dist/services/example-generator.d.ts.map +1 -0
- package/dist/services/example-generator.js +970 -0
- package/dist/services/example-generator.js.map +1 -0
- package/dist/services/execution-processor.d.ts +8 -0
- package/dist/services/execution-processor.d.ts.map +1 -0
- package/dist/services/execution-processor.js +381 -0
- package/dist/services/execution-processor.js.map +1 -0
- package/dist/services/expression-format-validator.d.ts +33 -0
- package/dist/services/expression-format-validator.d.ts.map +1 -0
- package/dist/services/expression-format-validator.js +209 -0
- package/dist/services/expression-format-validator.js.map +1 -0
- package/dist/services/expression-validator.d.ts +27 -0
- package/dist/services/expression-validator.d.ts.map +1 -0
- package/dist/services/expression-validator.js +187 -0
- package/dist/services/expression-validator.js.map +1 -0
- package/dist/services/installed-node-sync-service.d.ts +32 -0
- package/dist/services/installed-node-sync-service.d.ts.map +1 -0
- package/dist/services/installed-node-sync-service.js +190 -0
- package/dist/services/installed-node-sync-service.js.map +1 -0
- package/dist/services/n8n-api-client.d.ts +48 -0
- package/dist/services/n8n-api-client.d.ts.map +1 -0
- package/dist/services/n8n-api-client.js +458 -0
- package/dist/services/n8n-api-client.js.map +1 -0
- package/dist/services/n8n-file-format.d.ts +58 -0
- package/dist/services/n8n-file-format.d.ts.map +1 -0
- package/dist/services/n8n-file-format.js +203 -0
- package/dist/services/n8n-file-format.js.map +1 -0
- package/dist/services/n8n-validation.d.ts +273 -0
- package/dist/services/n8n-validation.d.ts.map +1 -0
- package/dist/services/n8n-validation.js +491 -0
- package/dist/services/n8n-validation.js.map +1 -0
- package/dist/services/n8n-version.d.ts +23 -0
- package/dist/services/n8n-version.d.ts.map +1 -0
- package/dist/services/n8n-version.js +151 -0
- package/dist/services/n8n-version.js.map +1 -0
- package/dist/services/node-documentation-service.d.ts +70 -0
- package/dist/services/node-documentation-service.d.ts.map +1 -0
- package/dist/services/node-documentation-service.js +518 -0
- package/dist/services/node-documentation-service.js.map +1 -0
- package/dist/services/node-migration-service.d.ts +44 -0
- package/dist/services/node-migration-service.d.ts.map +1 -0
- package/dist/services/node-migration-service.js +231 -0
- package/dist/services/node-migration-service.js.map +1 -0
- package/dist/services/node-sanitizer.d.ts +5 -0
- package/dist/services/node-sanitizer.d.ts.map +1 -0
- package/dist/services/node-sanitizer.js +225 -0
- package/dist/services/node-sanitizer.js.map +1 -0
- package/dist/services/node-similarity-service.d.ts +51 -0
- package/dist/services/node-similarity-service.d.ts.map +1 -0
- package/dist/services/node-similarity-service.js +352 -0
- package/dist/services/node-similarity-service.js.map +1 -0
- package/dist/services/node-specific-validators.d.ts +37 -0
- package/dist/services/node-specific-validators.d.ts.map +1 -0
- package/dist/services/node-specific-validators.js +1331 -0
- package/dist/services/node-specific-validators.js.map +1 -0
- package/dist/services/node-version-service.d.ts +63 -0
- package/dist/services/node-version-service.d.ts.map +1 -0
- package/dist/services/node-version-service.js +215 -0
- package/dist/services/node-version-service.js.map +1 -0
- package/dist/services/operation-similarity-service.d.ts +32 -0
- package/dist/services/operation-similarity-service.d.ts.map +1 -0
- package/dist/services/operation-similarity-service.js +341 -0
- package/dist/services/operation-similarity-service.js.map +1 -0
- package/dist/services/post-update-validator.d.ts +59 -0
- package/dist/services/post-update-validator.d.ts.map +1 -0
- package/dist/services/post-update-validator.js +231 -0
- package/dist/services/post-update-validator.js.map +1 -0
- package/dist/services/property-dependencies.d.ts +36 -0
- package/dist/services/property-dependencies.d.ts.map +1 -0
- package/dist/services/property-dependencies.js +168 -0
- package/dist/services/property-dependencies.js.map +1 -0
- package/dist/services/property-filter.d.ts +44 -0
- package/dist/services/property-filter.d.ts.map +1 -0
- package/dist/services/property-filter.js +395 -0
- package/dist/services/property-filter.js.map +1 -0
- package/dist/services/resource-similarity-service.d.ts +33 -0
- package/dist/services/resource-similarity-service.d.ts.map +1 -0
- package/dist/services/resource-similarity-service.js +358 -0
- package/dist/services/resource-similarity-service.js.map +1 -0
- package/dist/services/sqlite-storage-service.d.ts +11 -0
- package/dist/services/sqlite-storage-service.d.ts.map +1 -0
- package/dist/services/sqlite-storage-service.js +74 -0
- package/dist/services/sqlite-storage-service.js.map +1 -0
- package/dist/services/task-templates.d.ts +27 -0
- package/dist/services/task-templates.d.ts.map +1 -0
- package/dist/services/task-templates.js +1397 -0
- package/dist/services/task-templates.js.map +1 -0
- package/dist/services/tool-variant-generator.d.ts +10 -0
- package/dist/services/tool-variant-generator.d.ts.map +1 -0
- package/dist/services/tool-variant-generator.js +93 -0
- package/dist/services/tool-variant-generator.js.map +1 -0
- package/dist/services/type-structure-service.d.ts +23 -0
- package/dist/services/type-structure-service.d.ts.map +1 -0
- package/dist/services/type-structure-service.js +109 -0
- package/dist/services/type-structure-service.js.map +1 -0
- package/dist/services/universal-expression-validator.d.ts +20 -0
- package/dist/services/universal-expression-validator.d.ts.map +1 -0
- package/dist/services/universal-expression-validator.js +192 -0
- package/dist/services/universal-expression-validator.js.map +1 -0
- package/dist/services/workflow-analytics-service.d.ts +34 -0
- package/dist/services/workflow-analytics-service.d.ts.map +1 -0
- package/dist/services/workflow-analytics-service.js +144 -0
- package/dist/services/workflow-analytics-service.js.map +1 -0
- package/dist/services/workflow-auto-fixer.d.ts +74 -0
- package/dist/services/workflow-auto-fixer.d.ts.map +1 -0
- package/dist/services/workflow-auto-fixer.js +557 -0
- package/dist/services/workflow-auto-fixer.js.map +1 -0
- package/dist/services/workflow-comparison.d.ts +13 -0
- package/dist/services/workflow-comparison.d.ts.map +1 -0
- package/dist/services/workflow-comparison.js +306 -0
- package/dist/services/workflow-comparison.js.map +1 -0
- package/dist/services/workflow-debugging-service.d.ts +62 -0
- package/dist/services/workflow-debugging-service.d.ts.map +1 -0
- package/dist/services/workflow-debugging-service.js +153 -0
- package/dist/services/workflow-debugging-service.js.map +1 -0
- package/dist/services/workflow-diff-engine.d.ts +45 -0
- package/dist/services/workflow-diff-engine.d.ts.map +1 -0
- package/dist/services/workflow-diff-engine.js +830 -0
- package/dist/services/workflow-diff-engine.js.map +1 -0
- package/dist/services/workflow-validator.d.ts +112 -0
- package/dist/services/workflow-validator.d.ts.map +1 -0
- package/dist/services/workflow-validator.js +1328 -0
- package/dist/services/workflow-validator.js.map +1 -0
- package/dist/services/workflow-versioning-service.d.ts +102 -0
- package/dist/services/workflow-versioning-service.d.ts.map +1 -0
- package/dist/services/workflow-versioning-service.js +264 -0
- package/dist/services/workflow-versioning-service.js.map +1 -0
- package/dist/telemetry/batch-processor.d.ts +34 -0
- package/dist/telemetry/batch-processor.d.ts.map +1 -0
- package/dist/telemetry/batch-processor.js +337 -0
- package/dist/telemetry/batch-processor.js.map +1 -0
- package/dist/telemetry/config-manager.d.ts +32 -0
- package/dist/telemetry/config-manager.d.ts.map +1 -0
- package/dist/telemetry/config-manager.js +289 -0
- package/dist/telemetry/config-manager.js.map +1 -0
- package/dist/telemetry/early-error-logger.d.ts +26 -0
- package/dist/telemetry/early-error-logger.d.ts.map +1 -0
- package/dist/telemetry/early-error-logger.js +187 -0
- package/dist/telemetry/early-error-logger.js.map +1 -0
- package/dist/telemetry/error-sanitization-utils.d.ts +2 -0
- package/dist/telemetry/error-sanitization-utils.d.ts.map +1 -0
- package/dist/telemetry/error-sanitization-utils.js +37 -0
- package/dist/telemetry/error-sanitization-utils.js.map +1 -0
- package/dist/telemetry/error-sanitizer.d.ts +4 -0
- package/dist/telemetry/error-sanitizer.d.ts.map +1 -0
- package/dist/telemetry/error-sanitizer.js +45 -0
- package/dist/telemetry/error-sanitizer.js.map +1 -0
- package/dist/telemetry/event-tracker.d.ts +71 -0
- package/dist/telemetry/event-tracker.d.ts.map +1 -0
- package/dist/telemetry/event-tracker.js +356 -0
- package/dist/telemetry/event-tracker.js.map +1 -0
- package/dist/telemetry/event-validator.d.ts +78 -0
- package/dist/telemetry/event-validator.d.ts.map +1 -0
- package/dist/telemetry/event-validator.js +227 -0
- package/dist/telemetry/event-validator.js.map +1 -0
- package/dist/telemetry/index.d.ts +5 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +11 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/intent-classifier.d.ts +11 -0
- package/dist/telemetry/intent-classifier.d.ts.map +1 -0
- package/dist/telemetry/intent-classifier.js +141 -0
- package/dist/telemetry/intent-classifier.js.map +1 -0
- package/dist/telemetry/intent-sanitizer.d.ts +9 -0
- package/dist/telemetry/intent-sanitizer.d.ts.map +1 -0
- package/dist/telemetry/intent-sanitizer.js +103 -0
- package/dist/telemetry/intent-sanitizer.js.map +1 -0
- package/dist/telemetry/mutation-tracker.d.ts +15 -0
- package/dist/telemetry/mutation-tracker.d.ts.map +1 -0
- package/dist/telemetry/mutation-tracker.js +177 -0
- package/dist/telemetry/mutation-tracker.js.map +1 -0
- package/dist/telemetry/mutation-types.d.ts +106 -0
- package/dist/telemetry/mutation-types.d.ts.map +1 -0
- package/dist/telemetry/mutation-types.js +18 -0
- package/dist/telemetry/mutation-types.js.map +1 -0
- package/dist/telemetry/mutation-validator.d.ts +20 -0
- package/dist/telemetry/mutation-validator.d.ts.map +1 -0
- package/dist/telemetry/mutation-validator.js +144 -0
- package/dist/telemetry/mutation-validator.js.map +1 -0
- package/dist/telemetry/performance-monitor.d.ts +113 -0
- package/dist/telemetry/performance-monitor.d.ts.map +1 -0
- package/dist/telemetry/performance-monitor.js +208 -0
- package/dist/telemetry/performance-monitor.js.map +1 -0
- package/dist/telemetry/rate-limiter.d.ts +30 -0
- package/dist/telemetry/rate-limiter.d.ts.map +1 -0
- package/dist/telemetry/rate-limiter.js +103 -0
- package/dist/telemetry/rate-limiter.js.map +1 -0
- package/dist/telemetry/startup-checkpoints.d.ts +26 -0
- package/dist/telemetry/startup-checkpoints.d.ts.map +1 -0
- package/dist/telemetry/startup-checkpoints.js +65 -0
- package/dist/telemetry/startup-checkpoints.js.map +1 -0
- package/dist/telemetry/telemetry-error.d.ts +44 -0
- package/dist/telemetry/telemetry-error.d.ts.map +1 -0
- package/dist/telemetry/telemetry-error.js +153 -0
- package/dist/telemetry/telemetry-error.js.map +1 -0
- package/dist/telemetry/telemetry-manager.d.ts +130 -0
- package/dist/telemetry/telemetry-manager.d.ts.map +1 -0
- package/dist/telemetry/telemetry-manager.js +257 -0
- package/dist/telemetry/telemetry-manager.js.map +1 -0
- package/dist/telemetry/telemetry-types.d.ts +103 -0
- package/dist/telemetry/telemetry-types.d.ts.map +1 -0
- package/dist/telemetry/telemetry-types.js +29 -0
- package/dist/telemetry/telemetry-types.js.map +1 -0
- package/dist/telemetry/workflow-sanitizer.d.ts +34 -0
- package/dist/telemetry/workflow-sanitizer.d.ts.map +1 -0
- package/dist/telemetry/workflow-sanitizer.js +242 -0
- package/dist/telemetry/workflow-sanitizer.js.map +1 -0
- package/dist/templates/batch-processor.d.ts +35 -0
- package/dist/templates/batch-processor.d.ts.map +1 -0
- package/dist/templates/batch-processor.js +320 -0
- package/dist/templates/batch-processor.js.map +1 -0
- package/dist/templates/metadata-generator.d.ts +52 -0
- package/dist/templates/metadata-generator.d.ts.map +1 -0
- package/dist/templates/metadata-generator.js +252 -0
- package/dist/templates/metadata-generator.js.map +1 -0
- package/dist/templates/template-fetcher.d.ts +45 -0
- package/dist/templates/template-fetcher.d.ts.map +1 -0
- package/dist/templates/template-fetcher.js +122 -0
- package/dist/templates/template-fetcher.js.map +1 -0
- package/dist/templates/template-repository.d.ts +93 -0
- package/dist/templates/template-repository.d.ts.map +1 -0
- package/dist/templates/template-repository.js +644 -0
- package/dist/templates/template-repository.js.map +1 -0
- package/dist/templates/template-service.d.ts +79 -0
- package/dist/templates/template-service.d.ts.map +1 -0
- package/dist/templates/template-service.js +300 -0
- package/dist/templates/template-service.js.map +1 -0
- package/dist/triggers/handlers/base-handler.d.ts +21 -0
- package/dist/triggers/handlers/base-handler.d.ts.map +1 -0
- package/dist/triggers/handlers/base-handler.js +60 -0
- package/dist/triggers/handlers/base-handler.js.map +1 -0
- package/dist/triggers/handlers/chat-handler.d.ts +38 -0
- package/dist/triggers/handlers/chat-handler.d.ts.map +1 -0
- package/dist/triggers/handlers/chat-handler.js +129 -0
- package/dist/triggers/handlers/chat-handler.js.map +1 -0
- package/dist/triggers/handlers/form-handler.d.ts +35 -0
- package/dist/triggers/handlers/form-handler.d.ts.map +1 -0
- package/dist/triggers/handlers/form-handler.js +362 -0
- package/dist/triggers/handlers/form-handler.js.map +1 -0
- package/dist/triggers/handlers/webhook-handler.d.ts +38 -0
- package/dist/triggers/handlers/webhook-handler.d.ts.map +1 -0
- package/dist/triggers/handlers/webhook-handler.js +115 -0
- package/dist/triggers/handlers/webhook-handler.js.map +1 -0
- package/dist/triggers/index.d.ts +5 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +14 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/trigger-detector.d.ts +6 -0
- package/dist/triggers/trigger-detector.d.ts.map +1 -0
- package/dist/triggers/trigger-detector.js +201 -0
- package/dist/triggers/trigger-detector.js.map +1 -0
- package/dist/triggers/trigger-registry.d.ts +18 -0
- package/dist/triggers/trigger-registry.d.ts.map +1 -0
- package/dist/triggers/trigger-registry.js +87 -0
- package/dist/triggers/trigger-registry.js.map +1 -0
- package/dist/triggers/types.d.ts +76 -0
- package/dist/triggers/types.d.ts.map +1 -0
- package/dist/triggers/types.js +3 -0
- package/dist/triggers/types.js.map +1 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/instance-context.d.ts +20 -0
- package/dist/types/instance-context.d.ts.map +1 -0
- package/dist/types/instance-context.js +153 -0
- package/dist/types/instance-context.js.map +1 -0
- package/dist/types/n8n-api.d.ts +376 -0
- package/dist/types/n8n-api.d.ts.map +1 -0
- package/dist/types/n8n-api.js +10 -0
- package/dist/types/n8n-api.js.map +1 -0
- package/dist/types/node-types.d.ts +19 -0
- package/dist/types/node-types.d.ts.map +1 -0
- package/dist/types/node-types.js +62 -0
- package/dist/types/node-types.js.map +1 -0
- package/dist/types/session-state.d.ts +15 -0
- package/dist/types/session-state.d.ts.map +1 -0
- package/dist/types/session-state.js +3 -0
- package/dist/types/session-state.js.map +1 -0
- package/dist/types/type-structures.d.ts +42 -0
- package/dist/types/type-structures.d.ts.map +1 -0
- package/dist/types/type-structures.js +32 -0
- package/dist/types/type-structures.js.map +1 -0
- package/dist/types/workflow-comparison.d.ts +51 -0
- package/dist/types/workflow-comparison.d.ts.map +1 -0
- package/dist/types/workflow-comparison.js +3 -0
- package/dist/types/workflow-comparison.js.map +1 -0
- package/dist/types/workflow-diff.d.ts +148 -0
- package/dist/types/workflow-diff.d.ts.map +1 -0
- package/dist/types/workflow-diff.js +15 -0
- package/dist/types/workflow-diff.js.map +1 -0
- package/dist/utils/auth.d.ts +13 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +82 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/bridge.d.ts +12 -0
- package/dist/utils/bridge.d.ts.map +1 -0
- package/dist/utils/bridge.js +127 -0
- package/dist/utils/bridge.js.map +1 -0
- package/dist/utils/cache-utils.d.ts +58 -0
- package/dist/utils/cache-utils.d.ts.map +1 -0
- package/dist/utils/cache-utils.js +243 -0
- package/dist/utils/cache-utils.js.map +1 -0
- package/dist/utils/console-manager.d.ts +10 -0
- package/dist/utils/console-manager.d.ts.map +1 -0
- package/dist/utils/console-manager.js +63 -0
- package/dist/utils/console-manager.js.map +1 -0
- package/dist/utils/documentation-fetcher.d.ts +2 -0
- package/dist/utils/documentation-fetcher.d.ts.map +1 -0
- package/dist/utils/documentation-fetcher.js +18 -0
- package/dist/utils/documentation-fetcher.js.map +1 -0
- package/dist/utils/enhanced-documentation-fetcher.d.ts +74 -0
- package/dist/utils/enhanced-documentation-fetcher.d.ts.map +1 -0
- package/dist/utils/enhanced-documentation-fetcher.js +521 -0
- package/dist/utils/enhanced-documentation-fetcher.js.map +1 -0
- package/dist/utils/error-handler.d.ts +24 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +84 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/example-generator.d.ts +8 -0
- package/dist/utils/example-generator.d.ts.map +1 -0
- package/dist/utils/example-generator.js +106 -0
- package/dist/utils/example-generator.js.map +1 -0
- package/dist/utils/expression-utils.d.ts +6 -0
- package/dist/utils/expression-utils.d.ts.map +1 -0
- package/dist/utils/expression-utils.js +47 -0
- package/dist/utils/expression-utils.js.map +1 -0
- package/dist/utils/fixed-collection-validator.d.ts +35 -0
- package/dist/utils/fixed-collection-validator.d.ts.map +1 -0
- package/dist/utils/fixed-collection-validator.js +358 -0
- package/dist/utils/fixed-collection-validator.js.map +1 -0
- package/dist/utils/logger.d.ts +33 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +101 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-client.d.ts +21 -0
- package/dist/utils/mcp-client.d.ts.map +1 -0
- package/dist/utils/mcp-client.js +96 -0
- package/dist/utils/mcp-client.js.map +1 -0
- package/dist/utils/n8n-errors.d.ts +27 -0
- package/dist/utils/n8n-errors.d.ts.map +1 -0
- package/dist/utils/n8n-errors.js +138 -0
- package/dist/utils/n8n-errors.js.map +1 -0
- package/dist/utils/node-classification.d.ts +5 -0
- package/dist/utils/node-classification.d.ts.map +1 -0
- package/dist/utils/node-classification.js +31 -0
- package/dist/utils/node-classification.js.map +1 -0
- package/dist/utils/node-source-extractor.d.ts +21 -0
- package/dist/utils/node-source-extractor.d.ts.map +1 -0
- package/dist/utils/node-source-extractor.js +377 -0
- package/dist/utils/node-source-extractor.js.map +1 -0
- package/dist/utils/node-type-normalizer.d.ts +17 -0
- package/dist/utils/node-type-normalizer.d.ts.map +1 -0
- package/dist/utils/node-type-normalizer.js +87 -0
- package/dist/utils/node-type-normalizer.js.map +1 -0
- package/dist/utils/node-type-utils.d.ts +12 -0
- package/dist/utils/node-type-utils.d.ts.map +1 -0
- package/dist/utils/node-type-utils.js +126 -0
- package/dist/utils/node-type-utils.js.map +1 -0
- package/dist/utils/node-utils.d.ts +4 -0
- package/dist/utils/node-utils.d.ts.map +1 -0
- package/dist/utils/node-utils.js +81 -0
- package/dist/utils/node-utils.js.map +1 -0
- package/dist/utils/npm-version-checker.d.ts +14 -0
- package/dist/utils/npm-version-checker.d.ts.map +1 -0
- package/dist/utils/npm-version-checker.js +125 -0
- package/dist/utils/npm-version-checker.js.map +1 -0
- package/dist/utils/protocol-version.d.ts +19 -0
- package/dist/utils/protocol-version.d.ts.map +1 -0
- package/dist/utils/protocol-version.js +95 -0
- package/dist/utils/protocol-version.js.map +1 -0
- package/dist/utils/simple-cache.d.ts +10 -0
- package/dist/utils/simple-cache.d.ts.map +1 -0
- package/dist/utils/simple-cache.js +42 -0
- package/dist/utils/simple-cache.js.map +1 -0
- package/dist/utils/ssrf-protection.d.ts +7 -0
- package/dist/utils/ssrf-protection.d.ts.map +1 -0
- package/dist/utils/ssrf-protection.js +118 -0
- package/dist/utils/ssrf-protection.js.map +1 -0
- package/dist/utils/template-node-resolver.d.ts +2 -0
- package/dist/utils/template-node-resolver.d.ts.map +1 -0
- package/dist/utils/template-node-resolver.js +161 -0
- package/dist/utils/template-node-resolver.js.map +1 -0
- package/dist/utils/template-sanitizer.d.ts +21 -0
- package/dist/utils/template-sanitizer.d.ts.map +1 -0
- package/dist/utils/template-sanitizer.js +126 -0
- package/dist/utils/template-sanitizer.js.map +1 -0
- package/dist/utils/url-detector.d.ts +9 -0
- package/dist/utils/url-detector.d.ts.map +1 -0
- package/dist/utils/url-detector.js +79 -0
- package/dist/utils/url-detector.js.map +1 -0
- package/dist/utils/validation-schemas.d.ts +32 -0
- package/dist/utils/validation-schemas.d.ts.map +1 -0
- package/dist/utils/validation-schemas.js +219 -0
- package/dist/utils/validation-schemas.js.map +1 -0
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +18 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +178 -0
- package/package.runtime.json +24 -0
|
@@ -0,0 +1,3299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.handleValidateWorkflowFile = exports.handleSyncWorkflow = exports.handleExportWorkflowFile = exports.handleImportWorkflowFile = void 0;
|
|
37
|
+
exports.getInstanceCacheStatistics = getInstanceCacheStatistics;
|
|
38
|
+
exports.getInstanceCacheMetrics = getInstanceCacheMetrics;
|
|
39
|
+
exports.clearInstanceCache = clearInstanceCache;
|
|
40
|
+
exports.getN8nApiClient = getN8nApiClient;
|
|
41
|
+
exports.handleCreateWorkflow = handleCreateWorkflow;
|
|
42
|
+
exports.handleGetWorkflow = handleGetWorkflow;
|
|
43
|
+
exports.handleGetWorkflowDetails = handleGetWorkflowDetails;
|
|
44
|
+
exports.handleGetWorkflowStructure = handleGetWorkflowStructure;
|
|
45
|
+
exports.handleGetWorkflowMinimal = handleGetWorkflowMinimal;
|
|
46
|
+
exports.handleUpdateWorkflow = handleUpdateWorkflow;
|
|
47
|
+
exports.handleDeleteWorkflow = handleDeleteWorkflow;
|
|
48
|
+
exports.handleListWorkflows = handleListWorkflows;
|
|
49
|
+
exports.handleValidateWorkflow = handleValidateWorkflow;
|
|
50
|
+
exports.handleAutofixWorkflow = handleAutofixWorkflow;
|
|
51
|
+
exports.handleTestWorkflow = handleTestWorkflow;
|
|
52
|
+
exports.handleGetExecution = handleGetExecution;
|
|
53
|
+
exports.handleListExecutions = handleListExecutions;
|
|
54
|
+
exports.handleDeleteExecution = handleDeleteExecution;
|
|
55
|
+
exports.handleHealthCheck = handleHealthCheck;
|
|
56
|
+
exports.handleDiagnostic = handleDiagnostic;
|
|
57
|
+
exports.handleWorkflowVersions = handleWorkflowVersions;
|
|
58
|
+
exports.handleDeployTemplate = handleDeployTemplate;
|
|
59
|
+
exports.handleTriggerWebhookWorkflow = handleTriggerWebhookWorkflow;
|
|
60
|
+
exports.handleSearchCommunityNodes = handleSearchCommunityNodes;
|
|
61
|
+
exports.handleListCommunityPackages = handleListCommunityPackages;
|
|
62
|
+
exports.handleInstallCommunityPackage = handleInstallCommunityPackage;
|
|
63
|
+
exports.handleUninstallCommunityPackage = handleUninstallCommunityPackage;
|
|
64
|
+
exports.handleUpdateCommunityPackage = handleUpdateCommunityPackage;
|
|
65
|
+
exports.handleSyncInstalledNodes = handleSyncInstalledNodes;
|
|
66
|
+
exports.handleListCredentials = handleListCredentials;
|
|
67
|
+
exports.handleGetCredential = handleGetCredential;
|
|
68
|
+
exports.handleCreateCredential = handleCreateCredential;
|
|
69
|
+
exports.handleDeleteCredential = handleDeleteCredential;
|
|
70
|
+
exports.handleGetCredentialTypes = handleGetCredentialTypes;
|
|
71
|
+
exports.handleListTags = handleListTags;
|
|
72
|
+
exports.handleCreateTag = handleCreateTag;
|
|
73
|
+
exports.handleUpdateTag = handleUpdateTag;
|
|
74
|
+
exports.handleDeleteTag = handleDeleteTag;
|
|
75
|
+
exports.handleAssignTagsToWorkflow = handleAssignTagsToWorkflow;
|
|
76
|
+
exports.handleCloneWorkflow = handleCloneWorkflow;
|
|
77
|
+
exports.handleBackupWorkflows = handleBackupWorkflows;
|
|
78
|
+
exports.handleRestoreWorkflow = handleRestoreWorkflow;
|
|
79
|
+
exports.handleActivateWorkflow = handleActivateWorkflow;
|
|
80
|
+
exports.handleDeactivateWorkflow = handleDeactivateWorkflow;
|
|
81
|
+
exports.handleListActiveWorkflows = handleListActiveWorkflows;
|
|
82
|
+
exports.handleGetWorkflowStats = handleGetWorkflowStats;
|
|
83
|
+
exports.handleGetExecutionTrends = handleGetExecutionTrends;
|
|
84
|
+
exports.handleGetSlowWorkflows = handleGetSlowWorkflows;
|
|
85
|
+
exports.handleTraceExecution = handleTraceExecution;
|
|
86
|
+
exports.handleCompareExecutions = handleCompareExecutions;
|
|
87
|
+
const n8n_api_client_1 = require("../services/n8n-api-client");
|
|
88
|
+
const n8n_api_1 = require("../config/n8n-api");
|
|
89
|
+
const n8n_api_2 = require("../types/n8n-api");
|
|
90
|
+
const n8n_validation_1 = require("../services/n8n-validation");
|
|
91
|
+
const n8n_errors_1 = require("../utils/n8n-errors");
|
|
92
|
+
const logger_1 = require("../utils/logger");
|
|
93
|
+
const zod_1 = require("zod");
|
|
94
|
+
const workflow_validator_1 = require("../services/workflow-validator");
|
|
95
|
+
const enhanced_config_validator_1 = require("../services/enhanced-config-validator");
|
|
96
|
+
const instance_context_1 = require("../types/instance-context");
|
|
97
|
+
const workflow_auto_fixer_1 = require("../services/workflow-auto-fixer");
|
|
98
|
+
const expression_format_validator_1 = require("../services/expression-format-validator");
|
|
99
|
+
const workflow_versioning_service_1 = require("../services/workflow-versioning-service");
|
|
100
|
+
const handlers_workflow_diff_1 = require("./handlers-workflow-diff");
|
|
101
|
+
const telemetry_1 = require("../telemetry");
|
|
102
|
+
const cache_utils_1 = require("../utils/cache-utils");
|
|
103
|
+
const execution_processor_1 = require("../services/execution-processor");
|
|
104
|
+
const npm_version_checker_1 = require("../utils/npm-version-checker");
|
|
105
|
+
const tools_file_operations_1 = require("./tools-file-operations");
|
|
106
|
+
Object.defineProperty(exports, "handleImportWorkflowFile", { enumerable: true, get: function () { return tools_file_operations_1.handleImportWorkflowFile; } });
|
|
107
|
+
Object.defineProperty(exports, "handleExportWorkflowFile", { enumerable: true, get: function () { return tools_file_operations_1.handleExportWorkflowFile; } });
|
|
108
|
+
Object.defineProperty(exports, "handleSyncWorkflow", { enumerable: true, get: function () { return tools_file_operations_1.handleSyncWorkflow; } });
|
|
109
|
+
Object.defineProperty(exports, "handleValidateWorkflowFile", { enumerable: true, get: function () { return tools_file_operations_1.handleValidateWorkflowFile; } });
|
|
110
|
+
let defaultApiClient = null;
|
|
111
|
+
let lastDefaultConfigUrl = null;
|
|
112
|
+
const cacheMutex = new cache_utils_1.CacheMutex();
|
|
113
|
+
const instanceClients = (0, cache_utils_1.createInstanceCache)((client, key) => {
|
|
114
|
+
logger_1.logger.debug('Evicting API client from cache', {
|
|
115
|
+
cacheKey: key.substring(0, 8) + '...'
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
function getInstanceCacheStatistics() {
|
|
119
|
+
return (0, cache_utils_1.getCacheStatistics)();
|
|
120
|
+
}
|
|
121
|
+
function getInstanceCacheMetrics() {
|
|
122
|
+
return cache_utils_1.cacheMetrics.getMetrics();
|
|
123
|
+
}
|
|
124
|
+
function clearInstanceCache() {
|
|
125
|
+
instanceClients.clear();
|
|
126
|
+
cache_utils_1.cacheMetrics.recordClear();
|
|
127
|
+
cache_utils_1.cacheMetrics.updateSize(0, instanceClients.max);
|
|
128
|
+
}
|
|
129
|
+
function getN8nApiClient(context) {
|
|
130
|
+
if (context?.n8nApiUrl && context?.n8nApiKey) {
|
|
131
|
+
const validation = (0, instance_context_1.validateInstanceContext)(context);
|
|
132
|
+
if (!validation.valid) {
|
|
133
|
+
logger_1.logger.warn('Invalid instance context provided', {
|
|
134
|
+
instanceId: context.instanceId,
|
|
135
|
+
errors: validation.errors
|
|
136
|
+
});
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const cacheKey = (0, cache_utils_1.createCacheKey)(`${context.n8nApiUrl}:${context.n8nApiKey}:${context.instanceId || ''}`);
|
|
140
|
+
if (instanceClients.has(cacheKey)) {
|
|
141
|
+
cache_utils_1.cacheMetrics.recordHit();
|
|
142
|
+
return instanceClients.get(cacheKey) || null;
|
|
143
|
+
}
|
|
144
|
+
cache_utils_1.cacheMetrics.recordMiss();
|
|
145
|
+
if (cacheMutex.isLocked(cacheKey)) {
|
|
146
|
+
const waitTime = 100;
|
|
147
|
+
const start = Date.now();
|
|
148
|
+
while (cacheMutex.isLocked(cacheKey) && (Date.now() - start) < 1000) {
|
|
149
|
+
}
|
|
150
|
+
if (instanceClients.has(cacheKey)) {
|
|
151
|
+
cache_utils_1.cacheMetrics.recordHit();
|
|
152
|
+
return instanceClients.get(cacheKey) || null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const config = (0, n8n_api_1.getN8nApiConfigFromContext)(context);
|
|
156
|
+
if (config) {
|
|
157
|
+
logger_1.logger.info('Creating instance-specific n8n API client', {
|
|
158
|
+
url: config.baseUrl.replace(/^(https?:\/\/[^\/]+).*/, '$1'),
|
|
159
|
+
instanceId: context.instanceId,
|
|
160
|
+
cacheKey: cacheKey.substring(0, 8) + '...'
|
|
161
|
+
});
|
|
162
|
+
const client = new n8n_api_client_1.N8nApiClient(config);
|
|
163
|
+
instanceClients.set(cacheKey, client);
|
|
164
|
+
cache_utils_1.cacheMetrics.recordSet();
|
|
165
|
+
cache_utils_1.cacheMetrics.updateSize(instanceClients.size, instanceClients.max);
|
|
166
|
+
return client;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
logger_1.logger.info('Falling back to environment configuration for n8n API client');
|
|
171
|
+
const config = (0, n8n_api_1.getN8nApiConfig)();
|
|
172
|
+
if (!config) {
|
|
173
|
+
if (defaultApiClient) {
|
|
174
|
+
logger_1.logger.info('n8n API configuration removed, clearing default client');
|
|
175
|
+
defaultApiClient = null;
|
|
176
|
+
lastDefaultConfigUrl = null;
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
if (!defaultApiClient || lastDefaultConfigUrl !== config.baseUrl) {
|
|
181
|
+
logger_1.logger.info('n8n API client initialized from environment', { url: config.baseUrl });
|
|
182
|
+
defaultApiClient = new n8n_api_client_1.N8nApiClient(config);
|
|
183
|
+
lastDefaultConfigUrl = config.baseUrl;
|
|
184
|
+
}
|
|
185
|
+
return defaultApiClient;
|
|
186
|
+
}
|
|
187
|
+
function ensureApiConfigured(context) {
|
|
188
|
+
const client = getN8nApiClient(context);
|
|
189
|
+
if (!client) {
|
|
190
|
+
if (context?.instanceId) {
|
|
191
|
+
throw new Error(`n8n API not configured for instance ${context.instanceId}. Please provide n8nApiUrl and n8nApiKey in the instance context.`);
|
|
192
|
+
}
|
|
193
|
+
throw new Error('n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.');
|
|
194
|
+
}
|
|
195
|
+
return client;
|
|
196
|
+
}
|
|
197
|
+
const createWorkflowSchema = zod_1.z.object({
|
|
198
|
+
name: zod_1.z.string(),
|
|
199
|
+
nodes: zod_1.z.array(zod_1.z.any()),
|
|
200
|
+
connections: zod_1.z.record(zod_1.z.any()),
|
|
201
|
+
settings: zod_1.z.object({
|
|
202
|
+
executionOrder: zod_1.z.enum(['v0', 'v1']).optional(),
|
|
203
|
+
timezone: zod_1.z.string().optional(),
|
|
204
|
+
saveDataErrorExecution: zod_1.z.enum(['all', 'none']).optional(),
|
|
205
|
+
saveDataSuccessExecution: zod_1.z.enum(['all', 'none']).optional(),
|
|
206
|
+
saveManualExecutions: zod_1.z.boolean().optional(),
|
|
207
|
+
saveExecutionProgress: zod_1.z.boolean().optional(),
|
|
208
|
+
executionTimeout: zod_1.z.number().optional(),
|
|
209
|
+
errorWorkflow: zod_1.z.string().optional(),
|
|
210
|
+
}).optional(),
|
|
211
|
+
});
|
|
212
|
+
const updateWorkflowSchema = zod_1.z.object({
|
|
213
|
+
id: zod_1.z.string(),
|
|
214
|
+
name: zod_1.z.string().optional(),
|
|
215
|
+
nodes: zod_1.z.array(zod_1.z.any()).optional(),
|
|
216
|
+
connections: zod_1.z.record(zod_1.z.any()).optional(),
|
|
217
|
+
settings: zod_1.z.any().optional(),
|
|
218
|
+
createBackup: zod_1.z.boolean().optional(),
|
|
219
|
+
intent: zod_1.z.string().optional(),
|
|
220
|
+
});
|
|
221
|
+
const listWorkflowsSchema = zod_1.z.object({
|
|
222
|
+
limit: zod_1.z.number().min(1).max(100).optional(),
|
|
223
|
+
cursor: zod_1.z.string().optional(),
|
|
224
|
+
active: zod_1.z.boolean().optional(),
|
|
225
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
226
|
+
projectId: zod_1.z.string().optional(),
|
|
227
|
+
excludePinnedData: zod_1.z.boolean().optional(),
|
|
228
|
+
});
|
|
229
|
+
const validateWorkflowSchema = zod_1.z.object({
|
|
230
|
+
id: zod_1.z.string(),
|
|
231
|
+
options: zod_1.z.object({
|
|
232
|
+
validateNodes: zod_1.z.boolean().optional(),
|
|
233
|
+
validateConnections: zod_1.z.boolean().optional(),
|
|
234
|
+
validateExpressions: zod_1.z.boolean().optional(),
|
|
235
|
+
profile: zod_1.z.enum(['minimal', 'runtime', 'ai-friendly', 'strict']).optional(),
|
|
236
|
+
}).optional(),
|
|
237
|
+
});
|
|
238
|
+
const autofixWorkflowSchema = zod_1.z.object({
|
|
239
|
+
id: zod_1.z.string(),
|
|
240
|
+
applyFixes: zod_1.z.boolean().optional().default(false),
|
|
241
|
+
fixTypes: zod_1.z.array(zod_1.z.enum([
|
|
242
|
+
'expression-format',
|
|
243
|
+
'typeversion-correction',
|
|
244
|
+
'error-output-config',
|
|
245
|
+
'node-type-correction',
|
|
246
|
+
'webhook-missing-path',
|
|
247
|
+
'typeversion-upgrade',
|
|
248
|
+
'version-migration'
|
|
249
|
+
])).optional(),
|
|
250
|
+
confidenceThreshold: zod_1.z.enum(['high', 'medium', 'low']).optional().default('medium'),
|
|
251
|
+
maxFixes: zod_1.z.number().optional().default(50)
|
|
252
|
+
});
|
|
253
|
+
const testWorkflowSchema = zod_1.z.object({
|
|
254
|
+
workflowId: zod_1.z.string(),
|
|
255
|
+
triggerType: zod_1.z.enum(['webhook', 'form', 'chat']).optional(),
|
|
256
|
+
httpMethod: zod_1.z.enum(['GET', 'POST', 'PUT', 'DELETE']).optional(),
|
|
257
|
+
webhookPath: zod_1.z.string().optional(),
|
|
258
|
+
message: zod_1.z.string().optional(),
|
|
259
|
+
sessionId: zod_1.z.string().optional(),
|
|
260
|
+
data: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
261
|
+
headers: zod_1.z.record(zod_1.z.string()).optional(),
|
|
262
|
+
timeout: zod_1.z.number().optional(),
|
|
263
|
+
waitForResponse: zod_1.z.boolean().optional(),
|
|
264
|
+
});
|
|
265
|
+
const listExecutionsSchema = zod_1.z.object({
|
|
266
|
+
limit: zod_1.z.number().min(1).max(100).optional(),
|
|
267
|
+
cursor: zod_1.z.string().optional(),
|
|
268
|
+
workflowId: zod_1.z.string().optional(),
|
|
269
|
+
projectId: zod_1.z.string().optional(),
|
|
270
|
+
status: zod_1.z.enum(['success', 'error', 'waiting']).optional(),
|
|
271
|
+
includeData: zod_1.z.boolean().optional(),
|
|
272
|
+
});
|
|
273
|
+
const workflowVersionsSchema = zod_1.z.object({
|
|
274
|
+
mode: zod_1.z.enum(['list', 'get', 'rollback', 'delete', 'prune', 'truncate']),
|
|
275
|
+
workflowId: zod_1.z.string().optional(),
|
|
276
|
+
versionId: zod_1.z.number().optional(),
|
|
277
|
+
limit: zod_1.z.number().default(10).optional(),
|
|
278
|
+
validateBefore: zod_1.z.boolean().default(true).optional(),
|
|
279
|
+
deleteAll: zod_1.z.boolean().default(false).optional(),
|
|
280
|
+
maxVersions: zod_1.z.number().default(10).optional(),
|
|
281
|
+
confirmTruncate: zod_1.z.boolean().default(false).optional(),
|
|
282
|
+
});
|
|
283
|
+
async function handleCreateWorkflow(args, context) {
|
|
284
|
+
try {
|
|
285
|
+
const client = ensureApiConfigured(context);
|
|
286
|
+
const input = createWorkflowSchema.parse(args);
|
|
287
|
+
const shortFormErrors = [];
|
|
288
|
+
input.nodes?.forEach((node, index) => {
|
|
289
|
+
if (node.type?.startsWith('nodes-base.') || node.type?.startsWith('nodes-langchain.')) {
|
|
290
|
+
const fullForm = node.type.startsWith('nodes-base.')
|
|
291
|
+
? node.type.replace('nodes-base.', 'n8n-nodes-base.')
|
|
292
|
+
: node.type.replace('nodes-langchain.', '@n8n/n8n-nodes-langchain.');
|
|
293
|
+
shortFormErrors.push(`Node ${index} ("${node.name}") uses SHORT form "${node.type}". ` +
|
|
294
|
+
`The n8n API requires FULL form. Change to "${fullForm}"`);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
if (shortFormErrors.length > 0) {
|
|
298
|
+
telemetry_1.telemetry.trackWorkflowCreation(input, false);
|
|
299
|
+
return {
|
|
300
|
+
success: false,
|
|
301
|
+
error: 'Node type format error: n8n API requires FULL form node types',
|
|
302
|
+
details: {
|
|
303
|
+
errors: shortFormErrors,
|
|
304
|
+
hint: 'Use n8n-nodes-base.* instead of nodes-base.* for standard nodes'
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const errors = (0, n8n_validation_1.validateWorkflowStructure)(input);
|
|
309
|
+
if (errors.length > 0) {
|
|
310
|
+
telemetry_1.telemetry.trackWorkflowCreation(input, false);
|
|
311
|
+
return {
|
|
312
|
+
success: false,
|
|
313
|
+
error: 'Workflow validation failed',
|
|
314
|
+
details: { errors }
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const workflow = await client.createWorkflow(input);
|
|
318
|
+
telemetry_1.telemetry.trackWorkflowCreation(workflow, true);
|
|
319
|
+
return {
|
|
320
|
+
success: true,
|
|
321
|
+
data: {
|
|
322
|
+
id: workflow.id,
|
|
323
|
+
name: workflow.name,
|
|
324
|
+
active: workflow.active,
|
|
325
|
+
nodeCount: workflow.nodes?.length || 0
|
|
326
|
+
},
|
|
327
|
+
message: `Workflow "${workflow.name}" created successfully with ID: ${workflow.id}. Use n8n_get_workflow with mode 'structure' to verify current state.`
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
332
|
+
return {
|
|
333
|
+
success: false,
|
|
334
|
+
error: 'Invalid input',
|
|
335
|
+
details: { errors: error.errors }
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
339
|
+
return {
|
|
340
|
+
success: false,
|
|
341
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
342
|
+
code: error.code,
|
|
343
|
+
details: error.details
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
success: false,
|
|
348
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async function handleGetWorkflow(args, context) {
|
|
353
|
+
try {
|
|
354
|
+
const client = ensureApiConfigured(context);
|
|
355
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
356
|
+
const workflow = await client.getWorkflow(id);
|
|
357
|
+
return {
|
|
358
|
+
success: true,
|
|
359
|
+
data: workflow
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
364
|
+
return {
|
|
365
|
+
success: false,
|
|
366
|
+
error: 'Invalid input',
|
|
367
|
+
details: { errors: error.errors }
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
371
|
+
return {
|
|
372
|
+
success: false,
|
|
373
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
374
|
+
code: error.code
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
success: false,
|
|
379
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async function handleGetWorkflowDetails(args, context) {
|
|
384
|
+
try {
|
|
385
|
+
const client = ensureApiConfigured(context);
|
|
386
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
387
|
+
const workflow = await client.getWorkflow(id);
|
|
388
|
+
const executions = await client.listExecutions({
|
|
389
|
+
workflowId: id,
|
|
390
|
+
limit: 10
|
|
391
|
+
});
|
|
392
|
+
const stats = {
|
|
393
|
+
totalExecutions: executions.data.length,
|
|
394
|
+
successCount: executions.data.filter(e => e.status === n8n_api_2.ExecutionStatus.SUCCESS).length,
|
|
395
|
+
errorCount: executions.data.filter(e => e.status === n8n_api_2.ExecutionStatus.ERROR).length,
|
|
396
|
+
lastExecutionTime: executions.data[0]?.startedAt || null
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
success: true,
|
|
400
|
+
data: {
|
|
401
|
+
workflow,
|
|
402
|
+
executionStats: stats,
|
|
403
|
+
hasWebhookTrigger: (0, n8n_validation_1.hasWebhookTrigger)(workflow),
|
|
404
|
+
webhookPath: (0, n8n_validation_1.getWebhookUrl)(workflow)
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
410
|
+
return {
|
|
411
|
+
success: false,
|
|
412
|
+
error: 'Invalid input',
|
|
413
|
+
details: { errors: error.errors }
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
417
|
+
return {
|
|
418
|
+
success: false,
|
|
419
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
420
|
+
code: error.code
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
success: false,
|
|
425
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
async function handleGetWorkflowStructure(args, context) {
|
|
430
|
+
try {
|
|
431
|
+
const client = ensureApiConfigured(context);
|
|
432
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
433
|
+
const workflow = await client.getWorkflow(id);
|
|
434
|
+
const simplifiedNodes = workflow.nodes.map(node => ({
|
|
435
|
+
id: node.id,
|
|
436
|
+
name: node.name,
|
|
437
|
+
type: node.type,
|
|
438
|
+
position: node.position,
|
|
439
|
+
disabled: node.disabled || false
|
|
440
|
+
}));
|
|
441
|
+
return {
|
|
442
|
+
success: true,
|
|
443
|
+
data: {
|
|
444
|
+
id: workflow.id,
|
|
445
|
+
name: workflow.name,
|
|
446
|
+
active: workflow.active,
|
|
447
|
+
isArchived: workflow.isArchived,
|
|
448
|
+
nodes: simplifiedNodes,
|
|
449
|
+
connections: workflow.connections,
|
|
450
|
+
nodeCount: workflow.nodes.length,
|
|
451
|
+
connectionCount: Object.keys(workflow.connections).length
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
457
|
+
return {
|
|
458
|
+
success: false,
|
|
459
|
+
error: 'Invalid input',
|
|
460
|
+
details: { errors: error.errors }
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
464
|
+
return {
|
|
465
|
+
success: false,
|
|
466
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
467
|
+
code: error.code
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
return {
|
|
471
|
+
success: false,
|
|
472
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async function handleGetWorkflowMinimal(args, context) {
|
|
477
|
+
try {
|
|
478
|
+
const client = ensureApiConfigured(context);
|
|
479
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
480
|
+
const workflow = await client.getWorkflow(id);
|
|
481
|
+
return {
|
|
482
|
+
success: true,
|
|
483
|
+
data: {
|
|
484
|
+
id: workflow.id,
|
|
485
|
+
name: workflow.name,
|
|
486
|
+
active: workflow.active,
|
|
487
|
+
isArchived: workflow.isArchived,
|
|
488
|
+
tags: workflow.tags || [],
|
|
489
|
+
createdAt: workflow.createdAt,
|
|
490
|
+
updatedAt: workflow.updatedAt
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
catch (error) {
|
|
495
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
496
|
+
return {
|
|
497
|
+
success: false,
|
|
498
|
+
error: 'Invalid input',
|
|
499
|
+
details: { errors: error.errors }
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
503
|
+
return {
|
|
504
|
+
success: false,
|
|
505
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
506
|
+
code: error.code
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
success: false,
|
|
511
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async function handleUpdateWorkflow(args, repository, context) {
|
|
516
|
+
const startTime = Date.now();
|
|
517
|
+
const sessionId = `mutation_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
518
|
+
let workflowBefore = null;
|
|
519
|
+
let userIntent = 'Full workflow update';
|
|
520
|
+
try {
|
|
521
|
+
const client = ensureApiConfigured(context);
|
|
522
|
+
const input = updateWorkflowSchema.parse(args);
|
|
523
|
+
const { id, createBackup, intent, ...updateData } = input;
|
|
524
|
+
userIntent = intent || 'Full workflow update';
|
|
525
|
+
if (updateData.nodes || updateData.connections) {
|
|
526
|
+
const current = await client.getWorkflow(id);
|
|
527
|
+
workflowBefore = JSON.parse(JSON.stringify(current));
|
|
528
|
+
if (createBackup !== false) {
|
|
529
|
+
try {
|
|
530
|
+
const versioningService = new workflow_versioning_service_1.WorkflowVersioningService(repository, client);
|
|
531
|
+
const backupResult = await versioningService.createBackup(id, current, {
|
|
532
|
+
trigger: 'full_update'
|
|
533
|
+
});
|
|
534
|
+
logger_1.logger.info('Workflow backup created', {
|
|
535
|
+
workflowId: id,
|
|
536
|
+
versionId: backupResult.versionId,
|
|
537
|
+
versionNumber: backupResult.versionNumber,
|
|
538
|
+
pruned: backupResult.pruned
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
catch (error) {
|
|
542
|
+
logger_1.logger.warn('Failed to create workflow backup', {
|
|
543
|
+
workflowId: id,
|
|
544
|
+
error: error.message
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const fullWorkflow = {
|
|
549
|
+
...current,
|
|
550
|
+
...updateData
|
|
551
|
+
};
|
|
552
|
+
const errors = (0, n8n_validation_1.validateWorkflowStructure)(fullWorkflow);
|
|
553
|
+
if (errors.length > 0) {
|
|
554
|
+
return {
|
|
555
|
+
success: false,
|
|
556
|
+
error: 'Workflow validation failed',
|
|
557
|
+
details: { errors }
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const workflow = await client.updateWorkflow(id, updateData);
|
|
562
|
+
if (workflowBefore) {
|
|
563
|
+
trackWorkflowMutationForFullUpdate({
|
|
564
|
+
sessionId,
|
|
565
|
+
toolName: 'n8n_update_full_workflow',
|
|
566
|
+
userIntent,
|
|
567
|
+
operations: [],
|
|
568
|
+
workflowBefore,
|
|
569
|
+
workflowAfter: workflow,
|
|
570
|
+
mutationSuccess: true,
|
|
571
|
+
durationMs: Date.now() - startTime,
|
|
572
|
+
}).catch(err => {
|
|
573
|
+
logger_1.logger.warn('Failed to track mutation telemetry:', err);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
success: true,
|
|
578
|
+
data: {
|
|
579
|
+
id: workflow.id,
|
|
580
|
+
name: workflow.name,
|
|
581
|
+
active: workflow.active,
|
|
582
|
+
nodeCount: workflow.nodes?.length || 0
|
|
583
|
+
},
|
|
584
|
+
message: `Workflow "${workflow.name}" updated successfully. Use n8n_get_workflow with mode 'structure' to verify current state.`
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
catch (error) {
|
|
588
|
+
if (workflowBefore) {
|
|
589
|
+
trackWorkflowMutationForFullUpdate({
|
|
590
|
+
sessionId,
|
|
591
|
+
toolName: 'n8n_update_full_workflow',
|
|
592
|
+
userIntent,
|
|
593
|
+
operations: [],
|
|
594
|
+
workflowBefore,
|
|
595
|
+
workflowAfter: workflowBefore,
|
|
596
|
+
mutationSuccess: false,
|
|
597
|
+
mutationError: error instanceof Error ? error.message : 'Unknown error',
|
|
598
|
+
durationMs: Date.now() - startTime,
|
|
599
|
+
}).catch(err => {
|
|
600
|
+
logger_1.logger.warn('Failed to track mutation telemetry for failed operation:', err);
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
604
|
+
return {
|
|
605
|
+
success: false,
|
|
606
|
+
error: 'Invalid input',
|
|
607
|
+
details: { errors: error.errors }
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
611
|
+
return {
|
|
612
|
+
success: false,
|
|
613
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
614
|
+
code: error.code,
|
|
615
|
+
details: error.details
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
success: false,
|
|
620
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
async function trackWorkflowMutationForFullUpdate(data) {
|
|
625
|
+
try {
|
|
626
|
+
const { telemetry } = await Promise.resolve().then(() => __importStar(require('../telemetry/telemetry-manager.js')));
|
|
627
|
+
await telemetry.trackWorkflowMutation(data);
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
logger_1.logger.debug('Telemetry tracking failed:', error);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
async function handleDeleteWorkflow(args, context) {
|
|
634
|
+
try {
|
|
635
|
+
const client = ensureApiConfigured(context);
|
|
636
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
637
|
+
const deleted = await client.deleteWorkflow(id);
|
|
638
|
+
return {
|
|
639
|
+
success: true,
|
|
640
|
+
data: {
|
|
641
|
+
id: deleted?.id || id,
|
|
642
|
+
name: deleted?.name,
|
|
643
|
+
deleted: true
|
|
644
|
+
},
|
|
645
|
+
message: `Workflow "${deleted?.name || id}" deleted successfully.`
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
catch (error) {
|
|
649
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
650
|
+
return {
|
|
651
|
+
success: false,
|
|
652
|
+
error: 'Invalid input',
|
|
653
|
+
details: { errors: error.errors }
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
657
|
+
return {
|
|
658
|
+
success: false,
|
|
659
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
660
|
+
code: error.code
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
success: false,
|
|
665
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
async function handleListWorkflows(args, context) {
|
|
670
|
+
try {
|
|
671
|
+
const client = ensureApiConfigured(context);
|
|
672
|
+
const input = listWorkflowsSchema.parse(args || {});
|
|
673
|
+
const tagsParam = input.tags && input.tags.length > 0
|
|
674
|
+
? input.tags.join(',')
|
|
675
|
+
: undefined;
|
|
676
|
+
const response = await client.listWorkflows({
|
|
677
|
+
limit: input.limit || 100,
|
|
678
|
+
cursor: input.cursor,
|
|
679
|
+
active: input.active,
|
|
680
|
+
tags: tagsParam,
|
|
681
|
+
projectId: input.projectId,
|
|
682
|
+
excludePinnedData: input.excludePinnedData ?? true
|
|
683
|
+
});
|
|
684
|
+
const minimalWorkflows = response.data.map(workflow => ({
|
|
685
|
+
id: workflow.id,
|
|
686
|
+
name: workflow.name,
|
|
687
|
+
active: workflow.active,
|
|
688
|
+
isArchived: workflow.isArchived,
|
|
689
|
+
createdAt: workflow.createdAt,
|
|
690
|
+
updatedAt: workflow.updatedAt,
|
|
691
|
+
tags: workflow.tags || [],
|
|
692
|
+
nodeCount: workflow.nodes?.length || 0
|
|
693
|
+
}));
|
|
694
|
+
return {
|
|
695
|
+
success: true,
|
|
696
|
+
data: {
|
|
697
|
+
workflows: minimalWorkflows,
|
|
698
|
+
returned: minimalWorkflows.length,
|
|
699
|
+
nextCursor: response.nextCursor,
|
|
700
|
+
hasMore: !!response.nextCursor,
|
|
701
|
+
...(response.nextCursor ? {
|
|
702
|
+
_note: "More workflows available. Use cursor to get next page."
|
|
703
|
+
} : {})
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
catch (error) {
|
|
708
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
709
|
+
return {
|
|
710
|
+
success: false,
|
|
711
|
+
error: 'Invalid input',
|
|
712
|
+
details: { errors: error.errors }
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
716
|
+
return {
|
|
717
|
+
success: false,
|
|
718
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
719
|
+
code: error.code
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
success: false,
|
|
724
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
async function handleValidateWorkflow(args, repository, context) {
|
|
729
|
+
try {
|
|
730
|
+
const client = ensureApiConfigured(context);
|
|
731
|
+
const input = validateWorkflowSchema.parse(args);
|
|
732
|
+
const workflowResponse = await handleGetWorkflow({ id: input.id }, context);
|
|
733
|
+
if (!workflowResponse.success) {
|
|
734
|
+
return workflowResponse;
|
|
735
|
+
}
|
|
736
|
+
const workflow = workflowResponse.data;
|
|
737
|
+
const validator = new workflow_validator_1.WorkflowValidator(repository, enhanced_config_validator_1.EnhancedConfigValidator);
|
|
738
|
+
const validationResult = await validator.validateWorkflow(workflow, input.options);
|
|
739
|
+
const response = {
|
|
740
|
+
valid: validationResult.valid,
|
|
741
|
+
workflowId: workflow.id,
|
|
742
|
+
workflowName: workflow.name,
|
|
743
|
+
summary: {
|
|
744
|
+
totalNodes: validationResult.statistics.totalNodes,
|
|
745
|
+
enabledNodes: validationResult.statistics.enabledNodes,
|
|
746
|
+
triggerNodes: validationResult.statistics.triggerNodes,
|
|
747
|
+
validConnections: validationResult.statistics.validConnections,
|
|
748
|
+
invalidConnections: validationResult.statistics.invalidConnections,
|
|
749
|
+
expressionsValidated: validationResult.statistics.expressionsValidated,
|
|
750
|
+
errorCount: validationResult.errors.length,
|
|
751
|
+
warningCount: validationResult.warnings.length
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
if (validationResult.errors.length > 0) {
|
|
755
|
+
response.errors = validationResult.errors.map(e => ({
|
|
756
|
+
node: e.nodeName || 'workflow',
|
|
757
|
+
nodeName: e.nodeName,
|
|
758
|
+
message: e.message,
|
|
759
|
+
details: e.details
|
|
760
|
+
}));
|
|
761
|
+
}
|
|
762
|
+
if (validationResult.warnings.length > 0) {
|
|
763
|
+
response.warnings = validationResult.warnings.map(w => ({
|
|
764
|
+
node: w.nodeName || 'workflow',
|
|
765
|
+
nodeName: w.nodeName,
|
|
766
|
+
message: w.message,
|
|
767
|
+
details: w.details
|
|
768
|
+
}));
|
|
769
|
+
}
|
|
770
|
+
if (validationResult.suggestions.length > 0) {
|
|
771
|
+
response.suggestions = validationResult.suggestions;
|
|
772
|
+
}
|
|
773
|
+
if (validationResult.valid) {
|
|
774
|
+
telemetry_1.telemetry.trackWorkflowCreation(workflow, true);
|
|
775
|
+
}
|
|
776
|
+
return {
|
|
777
|
+
success: true,
|
|
778
|
+
data: response
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
catch (error) {
|
|
782
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
783
|
+
return {
|
|
784
|
+
success: false,
|
|
785
|
+
error: 'Invalid input',
|
|
786
|
+
details: { errors: error.errors }
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
790
|
+
return {
|
|
791
|
+
success: false,
|
|
792
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
793
|
+
code: error.code
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
success: false,
|
|
798
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
async function handleAutofixWorkflow(args, repository, context) {
|
|
803
|
+
try {
|
|
804
|
+
const client = ensureApiConfigured(context);
|
|
805
|
+
const input = autofixWorkflowSchema.parse(args);
|
|
806
|
+
const workflowResponse = await handleGetWorkflow({ id: input.id }, context);
|
|
807
|
+
if (!workflowResponse.success) {
|
|
808
|
+
return workflowResponse;
|
|
809
|
+
}
|
|
810
|
+
const workflow = workflowResponse.data;
|
|
811
|
+
const validator = new workflow_validator_1.WorkflowValidator(repository, enhanced_config_validator_1.EnhancedConfigValidator);
|
|
812
|
+
const validationResult = await validator.validateWorkflow(workflow, {
|
|
813
|
+
validateNodes: true,
|
|
814
|
+
validateConnections: true,
|
|
815
|
+
validateExpressions: true,
|
|
816
|
+
profile: 'ai-friendly'
|
|
817
|
+
});
|
|
818
|
+
const allFormatIssues = [];
|
|
819
|
+
for (const node of workflow.nodes) {
|
|
820
|
+
const formatContext = {
|
|
821
|
+
nodeType: node.type,
|
|
822
|
+
nodeName: node.name,
|
|
823
|
+
nodeId: node.id
|
|
824
|
+
};
|
|
825
|
+
const nodeFormatIssues = expression_format_validator_1.ExpressionFormatValidator.validateNodeParameters(node.parameters, formatContext);
|
|
826
|
+
const enrichedIssues = nodeFormatIssues.map(issue => ({
|
|
827
|
+
...issue,
|
|
828
|
+
nodeName: node.name,
|
|
829
|
+
nodeId: node.id
|
|
830
|
+
}));
|
|
831
|
+
allFormatIssues.push(...enrichedIssues);
|
|
832
|
+
}
|
|
833
|
+
const autoFixer = new workflow_auto_fixer_1.WorkflowAutoFixer(repository);
|
|
834
|
+
const fixResult = await autoFixer.generateFixes(workflow, validationResult, allFormatIssues, {
|
|
835
|
+
applyFixes: input.applyFixes,
|
|
836
|
+
fixTypes: input.fixTypes,
|
|
837
|
+
confidenceThreshold: input.confidenceThreshold,
|
|
838
|
+
maxFixes: input.maxFixes
|
|
839
|
+
});
|
|
840
|
+
if (fixResult.fixes.length === 0) {
|
|
841
|
+
return {
|
|
842
|
+
success: true,
|
|
843
|
+
data: {
|
|
844
|
+
workflowId: workflow.id,
|
|
845
|
+
workflowName: workflow.name,
|
|
846
|
+
message: 'No automatic fixes available for this workflow',
|
|
847
|
+
validationSummary: {
|
|
848
|
+
errors: validationResult.errors.length,
|
|
849
|
+
warnings: validationResult.warnings.length
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
if (!input.applyFixes) {
|
|
855
|
+
return {
|
|
856
|
+
success: true,
|
|
857
|
+
data: {
|
|
858
|
+
workflowId: workflow.id,
|
|
859
|
+
workflowName: workflow.name,
|
|
860
|
+
preview: true,
|
|
861
|
+
fixesAvailable: fixResult.fixes.length,
|
|
862
|
+
fixes: fixResult.fixes,
|
|
863
|
+
summary: fixResult.summary,
|
|
864
|
+
stats: fixResult.stats,
|
|
865
|
+
message: `${fixResult.fixes.length} fixes available. Set applyFixes=true to apply them.`
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
if (fixResult.operations.length > 0) {
|
|
870
|
+
const updateResult = await (0, handlers_workflow_diff_1.handleUpdatePartialWorkflow)({
|
|
871
|
+
id: workflow.id,
|
|
872
|
+
operations: fixResult.operations,
|
|
873
|
+
createBackup: true
|
|
874
|
+
}, repository, context);
|
|
875
|
+
if (!updateResult.success) {
|
|
876
|
+
return {
|
|
877
|
+
success: false,
|
|
878
|
+
error: 'Failed to apply fixes',
|
|
879
|
+
details: {
|
|
880
|
+
fixes: fixResult.fixes,
|
|
881
|
+
updateError: updateResult.error
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
return {
|
|
886
|
+
success: true,
|
|
887
|
+
data: {
|
|
888
|
+
workflowId: workflow.id,
|
|
889
|
+
workflowName: workflow.name,
|
|
890
|
+
fixesApplied: fixResult.fixes.length,
|
|
891
|
+
fixes: fixResult.fixes,
|
|
892
|
+
summary: fixResult.summary,
|
|
893
|
+
stats: fixResult.stats,
|
|
894
|
+
message: `Successfully applied ${fixResult.fixes.length} fixes to workflow "${workflow.name}"`
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
success: true,
|
|
900
|
+
data: {
|
|
901
|
+
workflowId: workflow.id,
|
|
902
|
+
workflowName: workflow.name,
|
|
903
|
+
message: 'No fixes needed'
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
catch (error) {
|
|
908
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
909
|
+
return {
|
|
910
|
+
success: false,
|
|
911
|
+
error: 'Invalid input',
|
|
912
|
+
details: { errors: error.errors }
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
916
|
+
return {
|
|
917
|
+
success: false,
|
|
918
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
919
|
+
code: error.code
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
return {
|
|
923
|
+
success: false,
|
|
924
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
async function handleTestWorkflow(args, context) {
|
|
929
|
+
try {
|
|
930
|
+
const client = ensureApiConfigured(context);
|
|
931
|
+
const input = testWorkflowSchema.parse(args);
|
|
932
|
+
const { detectTriggerFromWorkflow, ensureRegistryInitialized, TriggerRegistry, } = await Promise.resolve().then(() => __importStar(require('../triggers')));
|
|
933
|
+
await ensureRegistryInitialized();
|
|
934
|
+
const workflow = await client.getWorkflow(input.workflowId);
|
|
935
|
+
let triggerType = input.triggerType;
|
|
936
|
+
let triggerInfo;
|
|
937
|
+
const detection = detectTriggerFromWorkflow(workflow);
|
|
938
|
+
if (!triggerType) {
|
|
939
|
+
if (detection.detected && detection.trigger) {
|
|
940
|
+
triggerType = detection.trigger.type;
|
|
941
|
+
triggerInfo = detection.trigger;
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
return {
|
|
945
|
+
success: false,
|
|
946
|
+
error: 'Workflow cannot be triggered externally',
|
|
947
|
+
details: {
|
|
948
|
+
workflowId: input.workflowId,
|
|
949
|
+
reason: detection.reason,
|
|
950
|
+
hint: 'Only workflows with webhook, form, or chat triggers can be executed via the API. Add one of these trigger nodes to your workflow.',
|
|
951
|
+
},
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
if (detection.detected && detection.trigger?.type === triggerType) {
|
|
957
|
+
triggerInfo = detection.trigger;
|
|
958
|
+
}
|
|
959
|
+
else if (!detection.detected || detection.trigger?.type !== triggerType) {
|
|
960
|
+
return {
|
|
961
|
+
success: false,
|
|
962
|
+
error: `Workflow does not have a ${triggerType} trigger`,
|
|
963
|
+
details: {
|
|
964
|
+
workflowId: input.workflowId,
|
|
965
|
+
requestedTrigger: triggerType,
|
|
966
|
+
detectedTrigger: detection.trigger?.type || 'none',
|
|
967
|
+
hint: detection.detected
|
|
968
|
+
? `Workflow has a ${detection.trigger?.type} trigger. Either use that type or omit triggerType for auto-detection.`
|
|
969
|
+
: 'Workflow has no externally-triggerable triggers (webhook, form, or chat).',
|
|
970
|
+
},
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
const handler = TriggerRegistry.getHandler(triggerType, client, context);
|
|
975
|
+
if (!handler) {
|
|
976
|
+
return {
|
|
977
|
+
success: false,
|
|
978
|
+
error: `No handler registered for trigger type: ${triggerType}`,
|
|
979
|
+
details: {
|
|
980
|
+
supportedTypes: TriggerRegistry.getRegisteredTypes(),
|
|
981
|
+
},
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
if (handler.capabilities.requiresActiveWorkflow && !workflow.active) {
|
|
985
|
+
return {
|
|
986
|
+
success: false,
|
|
987
|
+
error: 'Workflow must be active to trigger via this method',
|
|
988
|
+
details: {
|
|
989
|
+
workflowId: input.workflowId,
|
|
990
|
+
triggerType,
|
|
991
|
+
hint: 'Activate the workflow in n8n using n8n_update_partial_workflow with [{type: "activateWorkflow"}]',
|
|
992
|
+
},
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
if (triggerType === 'chat' && !input.message) {
|
|
996
|
+
return {
|
|
997
|
+
success: false,
|
|
998
|
+
error: 'Chat trigger requires a message parameter',
|
|
999
|
+
details: {
|
|
1000
|
+
hint: 'Provide message="your message" for chat triggers',
|
|
1001
|
+
},
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
const triggerInput = {
|
|
1005
|
+
workflowId: input.workflowId,
|
|
1006
|
+
triggerType,
|
|
1007
|
+
httpMethod: input.httpMethod,
|
|
1008
|
+
webhookPath: input.webhookPath,
|
|
1009
|
+
message: input.message || '',
|
|
1010
|
+
sessionId: input.sessionId,
|
|
1011
|
+
data: input.data,
|
|
1012
|
+
formData: input.data,
|
|
1013
|
+
headers: input.headers,
|
|
1014
|
+
timeout: input.timeout,
|
|
1015
|
+
waitForResponse: input.waitForResponse,
|
|
1016
|
+
};
|
|
1017
|
+
const response = await handler.execute(triggerInput, workflow, triggerInfo);
|
|
1018
|
+
return {
|
|
1019
|
+
success: response.success,
|
|
1020
|
+
data: response.data,
|
|
1021
|
+
message: response.success
|
|
1022
|
+
? `Workflow triggered successfully via ${triggerType}`
|
|
1023
|
+
: response.error,
|
|
1024
|
+
executionId: response.executionId,
|
|
1025
|
+
workflowId: input.workflowId,
|
|
1026
|
+
details: {
|
|
1027
|
+
triggerType,
|
|
1028
|
+
metadata: response.metadata,
|
|
1029
|
+
...(response.details || {}),
|
|
1030
|
+
},
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
catch (error) {
|
|
1034
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1035
|
+
return {
|
|
1036
|
+
success: false,
|
|
1037
|
+
error: 'Invalid input',
|
|
1038
|
+
details: { errors: error.errors },
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1042
|
+
return {
|
|
1043
|
+
success: false,
|
|
1044
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1045
|
+
code: error.code,
|
|
1046
|
+
details: error.details,
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
return {
|
|
1050
|
+
success: false,
|
|
1051
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
async function handleGetExecution(args, context) {
|
|
1056
|
+
try {
|
|
1057
|
+
const client = ensureApiConfigured(context);
|
|
1058
|
+
const schema = zod_1.z.object({
|
|
1059
|
+
id: zod_1.z.string(),
|
|
1060
|
+
mode: zod_1.z.enum(['preview', 'summary', 'filtered', 'full', 'error']).optional(),
|
|
1061
|
+
nodeNames: zod_1.z.array(zod_1.z.string()).optional(),
|
|
1062
|
+
itemsLimit: zod_1.z.number().optional(),
|
|
1063
|
+
includeInputData: zod_1.z.boolean().optional(),
|
|
1064
|
+
includeData: zod_1.z.boolean().optional(),
|
|
1065
|
+
errorItemsLimit: zod_1.z.number().min(0).max(100).optional(),
|
|
1066
|
+
includeStackTrace: zod_1.z.boolean().optional(),
|
|
1067
|
+
includeExecutionPath: zod_1.z.boolean().optional(),
|
|
1068
|
+
fetchWorkflow: zod_1.z.boolean().optional()
|
|
1069
|
+
});
|
|
1070
|
+
const params = schema.parse(args);
|
|
1071
|
+
const { id, mode, nodeNames, itemsLimit, includeInputData, includeData, errorItemsLimit, includeStackTrace, includeExecutionPath, fetchWorkflow } = params;
|
|
1072
|
+
let effectiveMode = mode;
|
|
1073
|
+
if (!effectiveMode && includeData !== undefined) {
|
|
1074
|
+
effectiveMode = includeData ? 'summary' : undefined;
|
|
1075
|
+
}
|
|
1076
|
+
const fetchFullData = effectiveMode !== undefined || includeData === true;
|
|
1077
|
+
const execution = await client.getExecution(id, fetchFullData);
|
|
1078
|
+
if (!effectiveMode && !nodeNames && itemsLimit === undefined) {
|
|
1079
|
+
return {
|
|
1080
|
+
success: true,
|
|
1081
|
+
data: execution
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
let workflow;
|
|
1085
|
+
if (effectiveMode === 'error' && fetchWorkflow !== false && execution.workflowId) {
|
|
1086
|
+
try {
|
|
1087
|
+
workflow = await client.getWorkflow(execution.workflowId);
|
|
1088
|
+
}
|
|
1089
|
+
catch (e) {
|
|
1090
|
+
logger_1.logger.debug('Could not fetch workflow for error analysis', {
|
|
1091
|
+
workflowId: execution.workflowId,
|
|
1092
|
+
error: e instanceof Error ? e.message : 'Unknown error'
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
const filterOptions = {
|
|
1097
|
+
mode: effectiveMode,
|
|
1098
|
+
nodeNames,
|
|
1099
|
+
itemsLimit,
|
|
1100
|
+
includeInputData,
|
|
1101
|
+
errorItemsLimit,
|
|
1102
|
+
includeStackTrace,
|
|
1103
|
+
includeExecutionPath
|
|
1104
|
+
};
|
|
1105
|
+
const processedExecution = (0, execution_processor_1.processExecution)(execution, filterOptions, workflow);
|
|
1106
|
+
return {
|
|
1107
|
+
success: true,
|
|
1108
|
+
data: processedExecution
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
catch (error) {
|
|
1112
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1113
|
+
return {
|
|
1114
|
+
success: false,
|
|
1115
|
+
error: 'Invalid input',
|
|
1116
|
+
details: { errors: error.errors }
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1120
|
+
return {
|
|
1121
|
+
success: false,
|
|
1122
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1123
|
+
code: error.code
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
return {
|
|
1127
|
+
success: false,
|
|
1128
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
async function handleListExecutions(args, context) {
|
|
1133
|
+
try {
|
|
1134
|
+
const client = ensureApiConfigured(context);
|
|
1135
|
+
const input = listExecutionsSchema.parse(args || {});
|
|
1136
|
+
const response = await client.listExecutions({
|
|
1137
|
+
limit: input.limit || 100,
|
|
1138
|
+
cursor: input.cursor,
|
|
1139
|
+
workflowId: input.workflowId,
|
|
1140
|
+
projectId: input.projectId,
|
|
1141
|
+
status: input.status,
|
|
1142
|
+
includeData: input.includeData || false
|
|
1143
|
+
});
|
|
1144
|
+
return {
|
|
1145
|
+
success: true,
|
|
1146
|
+
data: {
|
|
1147
|
+
executions: response.data,
|
|
1148
|
+
returned: response.data.length,
|
|
1149
|
+
nextCursor: response.nextCursor,
|
|
1150
|
+
hasMore: !!response.nextCursor,
|
|
1151
|
+
...(response.nextCursor ? {
|
|
1152
|
+
_note: "More executions available. Use cursor to get next page."
|
|
1153
|
+
} : {})
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
catch (error) {
|
|
1158
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1159
|
+
return {
|
|
1160
|
+
success: false,
|
|
1161
|
+
error: 'Invalid input',
|
|
1162
|
+
details: { errors: error.errors }
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1166
|
+
return {
|
|
1167
|
+
success: false,
|
|
1168
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1169
|
+
code: error.code
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
return {
|
|
1173
|
+
success: false,
|
|
1174
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
async function handleDeleteExecution(args, context) {
|
|
1179
|
+
try {
|
|
1180
|
+
const client = ensureApiConfigured(context);
|
|
1181
|
+
const { id } = zod_1.z.object({ id: zod_1.z.string() }).parse(args);
|
|
1182
|
+
await client.deleteExecution(id);
|
|
1183
|
+
return {
|
|
1184
|
+
success: true,
|
|
1185
|
+
message: `Execution ${id} deleted successfully`
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
catch (error) {
|
|
1189
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1190
|
+
return {
|
|
1191
|
+
success: false,
|
|
1192
|
+
error: 'Invalid input',
|
|
1193
|
+
details: { errors: error.errors }
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1197
|
+
return {
|
|
1198
|
+
success: false,
|
|
1199
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1200
|
+
code: error.code
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
return {
|
|
1204
|
+
success: false,
|
|
1205
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
async function handleHealthCheck(context) {
|
|
1210
|
+
const startTime = Date.now();
|
|
1211
|
+
try {
|
|
1212
|
+
const client = ensureApiConfigured(context);
|
|
1213
|
+
const health = await client.healthCheck();
|
|
1214
|
+
const packageJson = require('../../package.json');
|
|
1215
|
+
const mcpVersion = packageJson.version;
|
|
1216
|
+
const supportedN8nVersion = packageJson.dependencies?.n8n?.replace(/[^0-9.]/g, '');
|
|
1217
|
+
const versionCheck = await (0, npm_version_checker_1.checkNpmVersion)();
|
|
1218
|
+
const cacheMetricsData = getInstanceCacheMetrics();
|
|
1219
|
+
const responseTime = Date.now() - startTime;
|
|
1220
|
+
const responseData = {
|
|
1221
|
+
status: health.status,
|
|
1222
|
+
instanceId: health.instanceId,
|
|
1223
|
+
n8nVersion: health.n8nVersion,
|
|
1224
|
+
features: health.features,
|
|
1225
|
+
apiUrl: (0, n8n_api_1.getN8nApiConfig)()?.baseUrl,
|
|
1226
|
+
mcpVersion,
|
|
1227
|
+
supportedN8nVersion,
|
|
1228
|
+
versionCheck: {
|
|
1229
|
+
current: versionCheck.currentVersion,
|
|
1230
|
+
latest: versionCheck.latestVersion,
|
|
1231
|
+
upToDate: !versionCheck.isOutdated,
|
|
1232
|
+
message: (0, npm_version_checker_1.formatVersionMessage)(versionCheck),
|
|
1233
|
+
...(versionCheck.updateCommand ? { updateCommand: versionCheck.updateCommand } : {})
|
|
1234
|
+
},
|
|
1235
|
+
performance: {
|
|
1236
|
+
responseTimeMs: responseTime,
|
|
1237
|
+
cacheHitRate: (cacheMetricsData.hits + cacheMetricsData.misses) > 0
|
|
1238
|
+
? ((cacheMetricsData.hits / (cacheMetricsData.hits + cacheMetricsData.misses)) * 100).toFixed(2) + '%'
|
|
1239
|
+
: 'N/A',
|
|
1240
|
+
cachedInstances: cacheMetricsData.size
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
responseData.nextSteps = [
|
|
1244
|
+
'• Create workflow: n8n_create_workflow',
|
|
1245
|
+
'• List workflows: n8n_list_workflows',
|
|
1246
|
+
'• Search nodes: search_nodes',
|
|
1247
|
+
'• Browse templates: search_templates'
|
|
1248
|
+
];
|
|
1249
|
+
if (versionCheck.isOutdated && versionCheck.latestVersion) {
|
|
1250
|
+
responseData.updateWarning = `⚠️ n8n-atom-mcp v${versionCheck.latestVersion} is available (you have v${versionCheck.currentVersion}). Update recommended.`;
|
|
1251
|
+
}
|
|
1252
|
+
telemetry_1.telemetry.trackEvent('health_check_completed', {
|
|
1253
|
+
success: true,
|
|
1254
|
+
responseTimeMs: responseTime,
|
|
1255
|
+
upToDate: !versionCheck.isOutdated,
|
|
1256
|
+
apiConnected: true
|
|
1257
|
+
});
|
|
1258
|
+
return {
|
|
1259
|
+
success: true,
|
|
1260
|
+
data: responseData
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
catch (error) {
|
|
1264
|
+
const responseTime = Date.now() - startTime;
|
|
1265
|
+
telemetry_1.telemetry.trackEvent('health_check_failed', {
|
|
1266
|
+
success: false,
|
|
1267
|
+
responseTimeMs: responseTime,
|
|
1268
|
+
errorType: error instanceof n8n_errors_1.N8nApiError ? error.code : 'unknown'
|
|
1269
|
+
});
|
|
1270
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1271
|
+
return {
|
|
1272
|
+
success: false,
|
|
1273
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1274
|
+
code: error.code,
|
|
1275
|
+
details: {
|
|
1276
|
+
apiUrl: (0, n8n_api_1.getN8nApiConfig)()?.baseUrl,
|
|
1277
|
+
hint: 'Check if n8n is running and API is enabled',
|
|
1278
|
+
troubleshooting: [
|
|
1279
|
+
'1. Verify n8n instance is running',
|
|
1280
|
+
'2. Check N8N_API_URL is correct',
|
|
1281
|
+
'3. Verify N8N_API_KEY has proper permissions',
|
|
1282
|
+
'4. Run n8n_health_check with mode="diagnostic" for detailed analysis'
|
|
1283
|
+
]
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
return {
|
|
1288
|
+
success: false,
|
|
1289
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
function detectCloudPlatform() {
|
|
1294
|
+
if (process.env.RAILWAY_ENVIRONMENT)
|
|
1295
|
+
return 'railway';
|
|
1296
|
+
if (process.env.RENDER)
|
|
1297
|
+
return 'render';
|
|
1298
|
+
if (process.env.FLY_APP_NAME)
|
|
1299
|
+
return 'fly';
|
|
1300
|
+
if (process.env.HEROKU_APP_NAME)
|
|
1301
|
+
return 'heroku';
|
|
1302
|
+
if (process.env.AWS_EXECUTION_ENV)
|
|
1303
|
+
return 'aws';
|
|
1304
|
+
if (process.env.KUBERNETES_SERVICE_HOST)
|
|
1305
|
+
return 'kubernetes';
|
|
1306
|
+
if (process.env.GOOGLE_CLOUD_PROJECT)
|
|
1307
|
+
return 'gcp';
|
|
1308
|
+
if (process.env.AZURE_FUNCTIONS_ENVIRONMENT)
|
|
1309
|
+
return 'azure';
|
|
1310
|
+
return null;
|
|
1311
|
+
}
|
|
1312
|
+
function getModeSpecificDebug(mcpMode) {
|
|
1313
|
+
if (mcpMode === 'http') {
|
|
1314
|
+
const port = process.env.MCP_PORT || process.env.PORT || 3000;
|
|
1315
|
+
return {
|
|
1316
|
+
mode: 'HTTP Server',
|
|
1317
|
+
port,
|
|
1318
|
+
authTokenConfigured: !!(process.env.MCP_AUTH_TOKEN || process.env.AUTH_TOKEN),
|
|
1319
|
+
corsEnabled: true,
|
|
1320
|
+
serverUrl: `http://localhost:${port}`,
|
|
1321
|
+
healthCheckUrl: `http://localhost:${port}/health`,
|
|
1322
|
+
troubleshooting: [
|
|
1323
|
+
`1. Test server health: curl http://localhost:${port}/health`,
|
|
1324
|
+
'2. Check browser console for CORS errors',
|
|
1325
|
+
'3. Verify MCP_AUTH_TOKEN or AUTH_TOKEN if authentication enabled',
|
|
1326
|
+
`4. Ensure port ${port} is not in use: lsof -i :${port} (macOS/Linux) or netstat -ano | findstr :${port} (Windows)`,
|
|
1327
|
+
'5. Check firewall settings for port access',
|
|
1328
|
+
'6. Review server logs for connection errors'
|
|
1329
|
+
],
|
|
1330
|
+
commonIssues: [
|
|
1331
|
+
'CORS policy blocking browser requests',
|
|
1332
|
+
'Port already in use by another application',
|
|
1333
|
+
'Authentication token mismatch',
|
|
1334
|
+
'Network firewall blocking connections'
|
|
1335
|
+
]
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
const configLocation = process.platform === 'darwin'
|
|
1340
|
+
? '~/Library/Application Support/Claude/claude_desktop_config.json'
|
|
1341
|
+
: process.platform === 'win32'
|
|
1342
|
+
? '%APPDATA%\\Claude\\claude_desktop_config.json'
|
|
1343
|
+
: '~/.config/Claude/claude_desktop_config.json';
|
|
1344
|
+
return {
|
|
1345
|
+
mode: 'Standard I/O (Claude Desktop)',
|
|
1346
|
+
configLocation,
|
|
1347
|
+
troubleshooting: [
|
|
1348
|
+
'1. Verify Claude Desktop config file exists and is valid JSON',
|
|
1349
|
+
'2. Check MCP server entry: {"mcpServers": {"n8n": {"command": "npx", "args": ["-y", "n8n-atom-mcp"]}}}',
|
|
1350
|
+
'3. Restart Claude Desktop after config changes',
|
|
1351
|
+
'4. Check Claude Desktop logs for startup errors',
|
|
1352
|
+
'5. Test npx can run: npx -y n8n-atom-mcp --version',
|
|
1353
|
+
'6. Verify executable permissions if using local installation'
|
|
1354
|
+
],
|
|
1355
|
+
commonIssues: [
|
|
1356
|
+
'Invalid JSON in claude_desktop_config.json',
|
|
1357
|
+
'Incorrect command or args in MCP server config',
|
|
1358
|
+
'Claude Desktop not restarted after config changes',
|
|
1359
|
+
'npx unable to download or run package',
|
|
1360
|
+
'Missing execute permissions on local binary'
|
|
1361
|
+
]
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function getDockerDebug(isDocker) {
|
|
1366
|
+
if (!isDocker)
|
|
1367
|
+
return null;
|
|
1368
|
+
return {
|
|
1369
|
+
containerDetected: true,
|
|
1370
|
+
troubleshooting: [
|
|
1371
|
+
'1. Verify volume mounts for data/nodes.db',
|
|
1372
|
+
'2. Check network connectivity to n8n instance',
|
|
1373
|
+
'3. Ensure ports are correctly mapped',
|
|
1374
|
+
'4. Review container logs: docker logs <container-name>',
|
|
1375
|
+
'5. Verify environment variables passed to container',
|
|
1376
|
+
'6. Check IS_DOCKER=true is set correctly'
|
|
1377
|
+
],
|
|
1378
|
+
commonIssues: [
|
|
1379
|
+
'Volume mount not persisting database',
|
|
1380
|
+
'Network isolation preventing n8n API access',
|
|
1381
|
+
'Port mapping conflicts',
|
|
1382
|
+
'Missing environment variables in container'
|
|
1383
|
+
]
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function getCloudPlatformDebug(cloudPlatform) {
|
|
1387
|
+
if (!cloudPlatform)
|
|
1388
|
+
return null;
|
|
1389
|
+
const platformGuides = {
|
|
1390
|
+
railway: {
|
|
1391
|
+
name: 'Railway',
|
|
1392
|
+
troubleshooting: [
|
|
1393
|
+
'1. Check Railway environment variables are set',
|
|
1394
|
+
'2. Verify deployment logs in Railway dashboard',
|
|
1395
|
+
'3. Ensure PORT matches Railway assigned port (automatic)',
|
|
1396
|
+
'4. Check networking configuration for external access'
|
|
1397
|
+
]
|
|
1398
|
+
},
|
|
1399
|
+
render: {
|
|
1400
|
+
name: 'Render',
|
|
1401
|
+
troubleshooting: [
|
|
1402
|
+
'1. Verify Render environment variables',
|
|
1403
|
+
'2. Check Render logs for startup errors',
|
|
1404
|
+
'3. Ensure health check endpoint is responding',
|
|
1405
|
+
'4. Verify instance type has sufficient resources'
|
|
1406
|
+
]
|
|
1407
|
+
},
|
|
1408
|
+
fly: {
|
|
1409
|
+
name: 'Fly.io',
|
|
1410
|
+
troubleshooting: [
|
|
1411
|
+
'1. Check Fly.io logs: flyctl logs',
|
|
1412
|
+
'2. Verify fly.toml configuration',
|
|
1413
|
+
'3. Ensure volumes are properly mounted',
|
|
1414
|
+
'4. Check app status: flyctl status'
|
|
1415
|
+
]
|
|
1416
|
+
},
|
|
1417
|
+
heroku: {
|
|
1418
|
+
name: 'Heroku',
|
|
1419
|
+
troubleshooting: [
|
|
1420
|
+
'1. Check Heroku logs: heroku logs --tail',
|
|
1421
|
+
'2. Verify Procfile configuration',
|
|
1422
|
+
'3. Ensure dynos are running: heroku ps',
|
|
1423
|
+
'4. Check environment variables: heroku config'
|
|
1424
|
+
]
|
|
1425
|
+
},
|
|
1426
|
+
kubernetes: {
|
|
1427
|
+
name: 'Kubernetes',
|
|
1428
|
+
troubleshooting: [
|
|
1429
|
+
'1. Check pod logs: kubectl logs <pod-name>',
|
|
1430
|
+
'2. Verify service and ingress configuration',
|
|
1431
|
+
'3. Check persistent volume claims',
|
|
1432
|
+
'4. Verify resource limits and requests'
|
|
1433
|
+
]
|
|
1434
|
+
},
|
|
1435
|
+
aws: {
|
|
1436
|
+
name: 'AWS',
|
|
1437
|
+
troubleshooting: [
|
|
1438
|
+
'1. Check CloudWatch logs',
|
|
1439
|
+
'2. Verify IAM roles and permissions',
|
|
1440
|
+
'3. Check security groups and networking',
|
|
1441
|
+
'4. Verify environment variables in service config'
|
|
1442
|
+
]
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
return platformGuides[cloudPlatform] || {
|
|
1446
|
+
name: cloudPlatform.toUpperCase(),
|
|
1447
|
+
troubleshooting: [
|
|
1448
|
+
'1. Check cloud platform logs',
|
|
1449
|
+
'2. Verify environment variables are set',
|
|
1450
|
+
'3. Check networking and port configuration',
|
|
1451
|
+
'4. Review platform-specific documentation'
|
|
1452
|
+
]
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
async function handleDiagnostic(request, context) {
|
|
1456
|
+
const startTime = Date.now();
|
|
1457
|
+
const verbose = request.params?.arguments?.verbose || false;
|
|
1458
|
+
const mcpMode = process.env.MCP_MODE || 'stdio';
|
|
1459
|
+
const isDocker = process.env.IS_DOCKER === 'true';
|
|
1460
|
+
const cloudPlatform = detectCloudPlatform();
|
|
1461
|
+
const envVars = {
|
|
1462
|
+
N8N_API_URL: process.env.N8N_API_URL || null,
|
|
1463
|
+
N8N_API_KEY: process.env.N8N_API_KEY ? '***configured***' : null,
|
|
1464
|
+
NODE_ENV: process.env.NODE_ENV || 'production',
|
|
1465
|
+
MCP_MODE: mcpMode,
|
|
1466
|
+
isDocker,
|
|
1467
|
+
cloudPlatform,
|
|
1468
|
+
nodeVersion: process.version,
|
|
1469
|
+
platform: process.platform
|
|
1470
|
+
};
|
|
1471
|
+
const apiConfig = (0, n8n_api_1.getN8nApiConfig)();
|
|
1472
|
+
const apiConfigured = apiConfig !== null;
|
|
1473
|
+
const apiClient = getN8nApiClient(context);
|
|
1474
|
+
let apiStatus = {
|
|
1475
|
+
configured: apiConfigured,
|
|
1476
|
+
connected: false,
|
|
1477
|
+
error: null,
|
|
1478
|
+
version: null
|
|
1479
|
+
};
|
|
1480
|
+
if (apiClient) {
|
|
1481
|
+
try {
|
|
1482
|
+
const health = await apiClient.healthCheck();
|
|
1483
|
+
apiStatus.connected = true;
|
|
1484
|
+
apiStatus.version = health.n8nVersion || 'unknown';
|
|
1485
|
+
}
|
|
1486
|
+
catch (error) {
|
|
1487
|
+
apiStatus.error = error instanceof Error ? error.message : 'Unknown error';
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
const documentationTools = 7;
|
|
1491
|
+
const managementTools = apiConfigured ? 13 : 0;
|
|
1492
|
+
const totalTools = documentationTools + managementTools;
|
|
1493
|
+
const versionCheck = await (0, npm_version_checker_1.checkNpmVersion)();
|
|
1494
|
+
const cacheMetricsData = getInstanceCacheMetrics();
|
|
1495
|
+
const responseTime = Date.now() - startTime;
|
|
1496
|
+
const diagnostic = {
|
|
1497
|
+
timestamp: new Date().toISOString(),
|
|
1498
|
+
environment: envVars,
|
|
1499
|
+
apiConfiguration: {
|
|
1500
|
+
configured: apiConfigured,
|
|
1501
|
+
status: apiStatus,
|
|
1502
|
+
config: apiConfig ? {
|
|
1503
|
+
baseUrl: apiConfig.baseUrl,
|
|
1504
|
+
timeout: apiConfig.timeout,
|
|
1505
|
+
maxRetries: apiConfig.maxRetries
|
|
1506
|
+
} : null
|
|
1507
|
+
},
|
|
1508
|
+
versionInfo: {
|
|
1509
|
+
current: versionCheck.currentVersion,
|
|
1510
|
+
latest: versionCheck.latestVersion,
|
|
1511
|
+
upToDate: !versionCheck.isOutdated,
|
|
1512
|
+
message: (0, npm_version_checker_1.formatVersionMessage)(versionCheck),
|
|
1513
|
+
...(versionCheck.updateCommand ? { updateCommand: versionCheck.updateCommand } : {})
|
|
1514
|
+
},
|
|
1515
|
+
toolsAvailability: {
|
|
1516
|
+
documentationTools: {
|
|
1517
|
+
count: documentationTools,
|
|
1518
|
+
enabled: true,
|
|
1519
|
+
description: 'Always available - node info, search, validation, etc.'
|
|
1520
|
+
},
|
|
1521
|
+
managementTools: {
|
|
1522
|
+
count: managementTools,
|
|
1523
|
+
enabled: apiConfigured,
|
|
1524
|
+
description: apiConfigured ?
|
|
1525
|
+
'Management tools are ENABLED - create, update, execute workflows' :
|
|
1526
|
+
'Management tools are DISABLED - configure N8N_API_URL and N8N_API_KEY to enable'
|
|
1527
|
+
},
|
|
1528
|
+
totalAvailable: totalTools
|
|
1529
|
+
},
|
|
1530
|
+
performance: {
|
|
1531
|
+
diagnosticResponseTimeMs: responseTime,
|
|
1532
|
+
cacheHitRate: (cacheMetricsData.hits + cacheMetricsData.misses) > 0
|
|
1533
|
+
? ((cacheMetricsData.hits / (cacheMetricsData.hits + cacheMetricsData.misses)) * 100).toFixed(2) + '%'
|
|
1534
|
+
: 'N/A',
|
|
1535
|
+
cachedInstances: cacheMetricsData.size
|
|
1536
|
+
},
|
|
1537
|
+
modeSpecificDebug: getModeSpecificDebug(mcpMode)
|
|
1538
|
+
};
|
|
1539
|
+
if (apiConfigured && apiStatus.connected) {
|
|
1540
|
+
diagnostic.nextSteps = {
|
|
1541
|
+
message: '✓ API connected! Here\'s what you can do:',
|
|
1542
|
+
recommended: [
|
|
1543
|
+
{
|
|
1544
|
+
action: 'n8n_list_workflows',
|
|
1545
|
+
description: 'See your existing workflows',
|
|
1546
|
+
timing: 'Fast (6 seconds median)'
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
action: 'n8n_create_workflow',
|
|
1550
|
+
description: 'Create a new workflow',
|
|
1551
|
+
timing: 'Typically 6-14 minutes to build'
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
action: 'search_nodes',
|
|
1555
|
+
description: 'Discover available nodes',
|
|
1556
|
+
timing: 'Fast - explore 500+ nodes'
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
action: 'search_templates',
|
|
1560
|
+
description: 'Browse pre-built workflows',
|
|
1561
|
+
timing: 'Find examples quickly'
|
|
1562
|
+
}
|
|
1563
|
+
],
|
|
1564
|
+
tips: [
|
|
1565
|
+
'82% of users start creating workflows after diagnostics - you\'re ready to go!',
|
|
1566
|
+
'Most common first action: n8n_update_partial_workflow (managing existing workflows)',
|
|
1567
|
+
'Use n8n_validate_workflow before deploying to catch issues early'
|
|
1568
|
+
]
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
else if (apiConfigured && !apiStatus.connected) {
|
|
1572
|
+
diagnostic.troubleshooting = {
|
|
1573
|
+
issue: '⚠️ API configured but connection failed',
|
|
1574
|
+
error: apiStatus.error,
|
|
1575
|
+
steps: [
|
|
1576
|
+
'1. Verify n8n instance is running and accessible',
|
|
1577
|
+
'2. Check N8N_API_URL is correct (currently: ' + apiConfig?.baseUrl + ')',
|
|
1578
|
+
'3. Test URL in browser: ' + apiConfig?.baseUrl + '/healthz',
|
|
1579
|
+
'4. Verify N8N_API_KEY has proper permissions',
|
|
1580
|
+
'5. Check firewall/network settings if using remote n8n',
|
|
1581
|
+
'6. Try running n8n_health_check again after fixes'
|
|
1582
|
+
],
|
|
1583
|
+
commonIssues: [
|
|
1584
|
+
'Wrong port number in N8N_API_URL',
|
|
1585
|
+
'API key doesn\'t have sufficient permissions',
|
|
1586
|
+
'n8n instance not running or crashed',
|
|
1587
|
+
'Network firewall blocking connection'
|
|
1588
|
+
],
|
|
1589
|
+
documentation: 'https://github.com/tungkl197/n8n-atom-mcp?tab=readme-ov-file#n8n-management-tools-optional---requires-api-configuration'
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
else {
|
|
1593
|
+
diagnostic.setupGuide = {
|
|
1594
|
+
message: 'n8n API not configured. You can still use documentation tools!',
|
|
1595
|
+
whatYouCanDoNow: {
|
|
1596
|
+
documentation: [
|
|
1597
|
+
{
|
|
1598
|
+
tool: 'search_nodes',
|
|
1599
|
+
description: 'Search 500+ n8n nodes',
|
|
1600
|
+
example: 'search_nodes({query: "slack"})'
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
tool: 'get_node_essentials',
|
|
1604
|
+
description: 'Get node configuration details',
|
|
1605
|
+
example: 'get_node_essentials({nodeType: "nodes-base.httpRequest"})'
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
tool: 'search_templates',
|
|
1609
|
+
description: 'Browse workflow templates',
|
|
1610
|
+
example: 'search_templates({query: "chatbot"})'
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
tool: 'validate_workflow',
|
|
1614
|
+
description: 'Validate workflow JSON',
|
|
1615
|
+
example: 'validate_workflow({workflow: {...}})'
|
|
1616
|
+
}
|
|
1617
|
+
],
|
|
1618
|
+
note: '14 documentation tools available without API configuration'
|
|
1619
|
+
},
|
|
1620
|
+
whatYouCannotDo: [
|
|
1621
|
+
'✗ Create/update workflows in n8n instance',
|
|
1622
|
+
'✗ List your workflows',
|
|
1623
|
+
'✗ Execute workflows',
|
|
1624
|
+
'✗ View execution results'
|
|
1625
|
+
],
|
|
1626
|
+
howToEnable: {
|
|
1627
|
+
steps: [
|
|
1628
|
+
'1. Get your n8n API key: [Your n8n instance]/settings/api',
|
|
1629
|
+
'2. Set environment variables:',
|
|
1630
|
+
' N8N_API_URL=https://your-n8n-instance.com',
|
|
1631
|
+
' N8N_API_KEY=your_api_key_here',
|
|
1632
|
+
'3. Restart the MCP server',
|
|
1633
|
+
'4. Run n8n_health_check with mode="diagnostic" to verify',
|
|
1634
|
+
'5. All 19 tools will be available!'
|
|
1635
|
+
],
|
|
1636
|
+
documentation: 'https://github.com/tungkl197/n8n-atom-mcp?tab=readme-ov-file#n8n-management-tools-optional---requires-api-configuration'
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
if (versionCheck.isOutdated && versionCheck.latestVersion) {
|
|
1641
|
+
diagnostic.updateWarning = {
|
|
1642
|
+
message: `⚠️ Update available: v${versionCheck.currentVersion} → v${versionCheck.latestVersion}`,
|
|
1643
|
+
command: versionCheck.updateCommand,
|
|
1644
|
+
benefits: [
|
|
1645
|
+
'Latest bug fixes and improvements',
|
|
1646
|
+
'New features and tools',
|
|
1647
|
+
'Better performance and reliability'
|
|
1648
|
+
]
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
const dockerDebug = getDockerDebug(isDocker);
|
|
1652
|
+
if (dockerDebug) {
|
|
1653
|
+
diagnostic.dockerDebug = dockerDebug;
|
|
1654
|
+
}
|
|
1655
|
+
const cloudDebug = getCloudPlatformDebug(cloudPlatform);
|
|
1656
|
+
if (cloudDebug) {
|
|
1657
|
+
diagnostic.cloudPlatformDebug = cloudDebug;
|
|
1658
|
+
}
|
|
1659
|
+
if (verbose) {
|
|
1660
|
+
diagnostic.debug = {
|
|
1661
|
+
processEnv: Object.keys(process.env).filter(key => key.startsWith('N8N_') || key.startsWith('MCP_')),
|
|
1662
|
+
nodeVersion: process.version,
|
|
1663
|
+
platform: process.platform,
|
|
1664
|
+
workingDirectory: process.cwd(),
|
|
1665
|
+
cacheMetrics: cacheMetricsData
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
telemetry_1.telemetry.trackEvent('diagnostic_completed', {
|
|
1669
|
+
success: true,
|
|
1670
|
+
apiConfigured,
|
|
1671
|
+
apiConnected: apiStatus.connected,
|
|
1672
|
+
toolsAvailable: totalTools,
|
|
1673
|
+
responseTimeMs: responseTime,
|
|
1674
|
+
upToDate: !versionCheck.isOutdated,
|
|
1675
|
+
verbose
|
|
1676
|
+
});
|
|
1677
|
+
return {
|
|
1678
|
+
success: true,
|
|
1679
|
+
data: diagnostic
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
async function handleWorkflowVersions(args, repository, context) {
|
|
1683
|
+
try {
|
|
1684
|
+
const input = workflowVersionsSchema.parse(args);
|
|
1685
|
+
const client = context ? getN8nApiClient(context) : null;
|
|
1686
|
+
const versioningService = new workflow_versioning_service_1.WorkflowVersioningService(repository, client || undefined);
|
|
1687
|
+
switch (input.mode) {
|
|
1688
|
+
case 'list': {
|
|
1689
|
+
if (!input.workflowId) {
|
|
1690
|
+
return {
|
|
1691
|
+
success: false,
|
|
1692
|
+
error: 'workflowId is required for list mode'
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
const versions = await versioningService.getVersionHistory(input.workflowId, input.limit);
|
|
1696
|
+
return {
|
|
1697
|
+
success: true,
|
|
1698
|
+
data: {
|
|
1699
|
+
workflowId: input.workflowId,
|
|
1700
|
+
versions,
|
|
1701
|
+
count: versions.length,
|
|
1702
|
+
message: `Found ${versions.length} version(s) for workflow ${input.workflowId}`
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
case 'get': {
|
|
1707
|
+
if (!input.versionId) {
|
|
1708
|
+
return {
|
|
1709
|
+
success: false,
|
|
1710
|
+
error: 'versionId is required for get mode'
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
const version = await versioningService.getVersion(input.versionId);
|
|
1714
|
+
if (!version) {
|
|
1715
|
+
return {
|
|
1716
|
+
success: false,
|
|
1717
|
+
error: `Version ${input.versionId} not found`
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
success: true,
|
|
1722
|
+
data: version
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
case 'rollback': {
|
|
1726
|
+
if (!input.workflowId) {
|
|
1727
|
+
return {
|
|
1728
|
+
success: false,
|
|
1729
|
+
error: 'workflowId is required for rollback mode'
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
if (!client) {
|
|
1733
|
+
return {
|
|
1734
|
+
success: false,
|
|
1735
|
+
error: 'n8n API not configured. Cannot perform rollback without API access.'
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
const result = await versioningService.restoreVersion(input.workflowId, input.versionId, input.validateBefore);
|
|
1739
|
+
return {
|
|
1740
|
+
success: result.success,
|
|
1741
|
+
data: result.success ? result : undefined,
|
|
1742
|
+
error: result.success ? undefined : result.message,
|
|
1743
|
+
details: result.success ? undefined : {
|
|
1744
|
+
validationErrors: result.validationErrors
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
case 'delete': {
|
|
1749
|
+
if (input.deleteAll) {
|
|
1750
|
+
if (!input.workflowId) {
|
|
1751
|
+
return {
|
|
1752
|
+
success: false,
|
|
1753
|
+
error: 'workflowId is required for deleteAll mode'
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
const result = await versioningService.deleteAllVersions(input.workflowId);
|
|
1757
|
+
return {
|
|
1758
|
+
success: true,
|
|
1759
|
+
data: {
|
|
1760
|
+
workflowId: input.workflowId,
|
|
1761
|
+
deleted: result.deleted,
|
|
1762
|
+
message: result.message
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
else {
|
|
1767
|
+
if (!input.versionId) {
|
|
1768
|
+
return {
|
|
1769
|
+
success: false,
|
|
1770
|
+
error: 'versionId is required for single version delete'
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
const result = await versioningService.deleteVersion(input.versionId);
|
|
1774
|
+
return {
|
|
1775
|
+
success: result.success,
|
|
1776
|
+
data: result.success ? { message: result.message } : undefined,
|
|
1777
|
+
error: result.success ? undefined : result.message
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
case 'prune': {
|
|
1782
|
+
if (!input.workflowId) {
|
|
1783
|
+
return {
|
|
1784
|
+
success: false,
|
|
1785
|
+
error: 'workflowId is required for prune mode'
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
const result = await versioningService.pruneVersions(input.workflowId, input.maxVersions || 10);
|
|
1789
|
+
return {
|
|
1790
|
+
success: true,
|
|
1791
|
+
data: {
|
|
1792
|
+
workflowId: input.workflowId,
|
|
1793
|
+
pruned: result.pruned,
|
|
1794
|
+
remaining: result.remaining,
|
|
1795
|
+
message: `Pruned ${result.pruned} old version(s), ${result.remaining} version(s) remaining`
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
case 'truncate': {
|
|
1800
|
+
if (!input.confirmTruncate) {
|
|
1801
|
+
return {
|
|
1802
|
+
success: false,
|
|
1803
|
+
error: 'confirmTruncate must be true to truncate all versions. This action cannot be undone.'
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
const result = await versioningService.truncateAllVersions(true);
|
|
1807
|
+
return {
|
|
1808
|
+
success: true,
|
|
1809
|
+
data: {
|
|
1810
|
+
deleted: result.deleted,
|
|
1811
|
+
message: result.message
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
default:
|
|
1816
|
+
return {
|
|
1817
|
+
success: false,
|
|
1818
|
+
error: `Unknown mode: ${input.mode}`
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
catch (error) {
|
|
1823
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1824
|
+
return {
|
|
1825
|
+
success: false,
|
|
1826
|
+
error: 'Invalid input',
|
|
1827
|
+
details: { errors: error.errors }
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
return {
|
|
1831
|
+
success: false,
|
|
1832
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
const deployTemplateSchema = zod_1.z.object({
|
|
1837
|
+
templateId: zod_1.z.number().positive().int(),
|
|
1838
|
+
name: zod_1.z.string().optional(),
|
|
1839
|
+
autoUpgradeVersions: zod_1.z.boolean().default(true),
|
|
1840
|
+
autoFix: zod_1.z.boolean().default(true),
|
|
1841
|
+
stripCredentials: zod_1.z.boolean().default(true)
|
|
1842
|
+
});
|
|
1843
|
+
async function handleDeployTemplate(args, templateService, repository, context) {
|
|
1844
|
+
try {
|
|
1845
|
+
const client = ensureApiConfigured(context);
|
|
1846
|
+
const input = deployTemplateSchema.parse(args);
|
|
1847
|
+
const template = await templateService.getTemplate(input.templateId, 'full');
|
|
1848
|
+
if (!template) {
|
|
1849
|
+
return {
|
|
1850
|
+
success: false,
|
|
1851
|
+
error: `Template ${input.templateId} not found`,
|
|
1852
|
+
details: {
|
|
1853
|
+
hint: 'Use search_templates to find available templates',
|
|
1854
|
+
templateUrl: `https://n8n.io/workflows/${input.templateId}`
|
|
1855
|
+
}
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
const workflow = JSON.parse(JSON.stringify(template.workflow));
|
|
1859
|
+
if (!workflow || !workflow.nodes) {
|
|
1860
|
+
return {
|
|
1861
|
+
success: false,
|
|
1862
|
+
error: 'Template has invalid workflow structure',
|
|
1863
|
+
details: { templateId: input.templateId }
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
const workflowName = input.name || template.name;
|
|
1867
|
+
const requiredCredentials = [];
|
|
1868
|
+
for (const node of workflow.nodes) {
|
|
1869
|
+
if (node.credentials && typeof node.credentials === 'object') {
|
|
1870
|
+
for (const [credType] of Object.entries(node.credentials)) {
|
|
1871
|
+
requiredCredentials.push({
|
|
1872
|
+
nodeType: node.type,
|
|
1873
|
+
nodeName: node.name,
|
|
1874
|
+
credentialType: credType
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
if (input.stripCredentials) {
|
|
1880
|
+
workflow.nodes = workflow.nodes.map((node) => {
|
|
1881
|
+
const { credentials, ...rest } = node;
|
|
1882
|
+
return rest;
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
if (input.autoUpgradeVersions) {
|
|
1886
|
+
const autoFixer = new workflow_auto_fixer_1.WorkflowAutoFixer(repository);
|
|
1887
|
+
const validator = new workflow_validator_1.WorkflowValidator(repository, enhanced_config_validator_1.EnhancedConfigValidator);
|
|
1888
|
+
const validationResult = await validator.validateWorkflow(workflow, {
|
|
1889
|
+
validateNodes: true,
|
|
1890
|
+
validateConnections: false,
|
|
1891
|
+
validateExpressions: false,
|
|
1892
|
+
profile: 'runtime'
|
|
1893
|
+
});
|
|
1894
|
+
const fixResult = await autoFixer.generateFixes(workflow, validationResult, [], { fixTypes: ['typeversion-upgrade', 'typeversion-correction'] });
|
|
1895
|
+
if (fixResult.operations.length > 0) {
|
|
1896
|
+
for (const op of fixResult.operations) {
|
|
1897
|
+
if (op.type === 'updateNode' && op.updates) {
|
|
1898
|
+
const node = workflow.nodes.find((n) => n.id === op.nodeId || n.name === op.nodeName);
|
|
1899
|
+
if (node) {
|
|
1900
|
+
for (const [path, value] of Object.entries(op.updates)) {
|
|
1901
|
+
if (path === 'typeVersion') {
|
|
1902
|
+
node.typeVersion = value;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
const triggerNode = workflow.nodes.find((n) => n.type?.includes('Trigger') ||
|
|
1911
|
+
n.type?.includes('webhook') ||
|
|
1912
|
+
n.type === 'n8n-nodes-base.webhook');
|
|
1913
|
+
const triggerType = triggerNode?.type?.split('.').pop() || 'manual';
|
|
1914
|
+
const createdWorkflow = await client.createWorkflow({
|
|
1915
|
+
name: workflowName,
|
|
1916
|
+
nodes: workflow.nodes,
|
|
1917
|
+
connections: workflow.connections,
|
|
1918
|
+
settings: workflow.settings || { executionOrder: 'v1' }
|
|
1919
|
+
});
|
|
1920
|
+
const apiConfig = context ? (0, n8n_api_1.getN8nApiConfigFromContext)(context) : (0, n8n_api_1.getN8nApiConfig)();
|
|
1921
|
+
const baseUrl = apiConfig?.baseUrl?.replace('/api/v1', '') || '';
|
|
1922
|
+
let fixesApplied = [];
|
|
1923
|
+
let fixSummary = '';
|
|
1924
|
+
let autoFixStatus = 'skipped';
|
|
1925
|
+
if (input.autoFix) {
|
|
1926
|
+
try {
|
|
1927
|
+
const autofixResult = await handleAutofixWorkflow({
|
|
1928
|
+
id: createdWorkflow.id,
|
|
1929
|
+
applyFixes: true,
|
|
1930
|
+
fixTypes: ['expression-format', 'typeversion-upgrade'],
|
|
1931
|
+
confidenceThreshold: 'medium'
|
|
1932
|
+
}, repository, context);
|
|
1933
|
+
if (autofixResult.success && autofixResult.data) {
|
|
1934
|
+
const fixData = autofixResult.data;
|
|
1935
|
+
autoFixStatus = 'success';
|
|
1936
|
+
if (fixData.fixesApplied && fixData.fixesApplied > 0) {
|
|
1937
|
+
fixesApplied = fixData.fixes || [];
|
|
1938
|
+
fixSummary = ` Auto-fixed ${fixData.fixesApplied} issue(s).`;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
catch (fixError) {
|
|
1943
|
+
autoFixStatus = 'failed';
|
|
1944
|
+
logger_1.logger.warn('Auto-fix failed after template deployment', {
|
|
1945
|
+
workflowId: createdWorkflow.id,
|
|
1946
|
+
error: fixError instanceof Error ? fixError.message : 'Unknown error'
|
|
1947
|
+
});
|
|
1948
|
+
fixSummary = ' Auto-fix failed (workflow deployed successfully).';
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
return {
|
|
1952
|
+
success: true,
|
|
1953
|
+
data: {
|
|
1954
|
+
workflowId: createdWorkflow.id,
|
|
1955
|
+
name: createdWorkflow.name,
|
|
1956
|
+
active: false,
|
|
1957
|
+
nodeCount: workflow.nodes.length,
|
|
1958
|
+
triggerType,
|
|
1959
|
+
requiredCredentials: requiredCredentials.length > 0 ? requiredCredentials : undefined,
|
|
1960
|
+
url: baseUrl ? `${baseUrl}/workflow/${createdWorkflow.id}` : undefined,
|
|
1961
|
+
templateId: input.templateId,
|
|
1962
|
+
templateUrl: template.url || `https://n8n.io/workflows/${input.templateId}`,
|
|
1963
|
+
autoFixStatus,
|
|
1964
|
+
fixesApplied: fixesApplied.length > 0 ? fixesApplied : undefined
|
|
1965
|
+
},
|
|
1966
|
+
message: `Workflow "${createdWorkflow.name}" deployed successfully from template ${input.templateId}.${fixSummary} ${requiredCredentials.length > 0
|
|
1967
|
+
? `Configure ${requiredCredentials.length} credential(s) in n8n to activate.`
|
|
1968
|
+
: ''}`
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
catch (error) {
|
|
1972
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
1973
|
+
return {
|
|
1974
|
+
success: false,
|
|
1975
|
+
error: 'Invalid input',
|
|
1976
|
+
details: { errors: error.errors }
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
1980
|
+
return {
|
|
1981
|
+
success: false,
|
|
1982
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
1983
|
+
code: error.code,
|
|
1984
|
+
details: error.details
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
return {
|
|
1988
|
+
success: false,
|
|
1989
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
async function handleTriggerWebhookWorkflow(args, context) {
|
|
1994
|
+
const triggerWebhookSchema = zod_1.z.object({
|
|
1995
|
+
webhookUrl: zod_1.z.string().url(),
|
|
1996
|
+
httpMethod: zod_1.z.enum(['GET', 'POST', 'PUT', 'DELETE']).optional(),
|
|
1997
|
+
data: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
1998
|
+
headers: zod_1.z.record(zod_1.z.string()).optional(),
|
|
1999
|
+
waitForResponse: zod_1.z.boolean().optional(),
|
|
2000
|
+
});
|
|
2001
|
+
try {
|
|
2002
|
+
const client = ensureApiConfigured(context);
|
|
2003
|
+
const input = triggerWebhookSchema.parse(args);
|
|
2004
|
+
const webhookRequest = {
|
|
2005
|
+
webhookUrl: input.webhookUrl,
|
|
2006
|
+
httpMethod: input.httpMethod || 'POST',
|
|
2007
|
+
data: input.data,
|
|
2008
|
+
headers: input.headers,
|
|
2009
|
+
waitForResponse: input.waitForResponse ?? true
|
|
2010
|
+
};
|
|
2011
|
+
const response = await client.triggerWebhook(webhookRequest);
|
|
2012
|
+
return {
|
|
2013
|
+
success: true,
|
|
2014
|
+
data: response,
|
|
2015
|
+
message: 'Webhook triggered successfully'
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
catch (error) {
|
|
2019
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2020
|
+
return {
|
|
2021
|
+
success: false,
|
|
2022
|
+
error: 'Invalid input',
|
|
2023
|
+
details: { errors: error.errors }
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2027
|
+
const errorData = error.details;
|
|
2028
|
+
const executionId = errorData?.executionId || errorData?.id || errorData?.execution?.id;
|
|
2029
|
+
const workflowId = errorData?.workflowId || errorData?.workflow?.id;
|
|
2030
|
+
if (executionId) {
|
|
2031
|
+
return {
|
|
2032
|
+
success: false,
|
|
2033
|
+
error: (0, n8n_errors_1.formatExecutionError)(executionId, workflowId),
|
|
2034
|
+
code: error.code,
|
|
2035
|
+
executionId,
|
|
2036
|
+
workflowId: workflowId || undefined
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
if (error.code === 'SERVER_ERROR' || error.statusCode && error.statusCode >= 500) {
|
|
2040
|
+
return {
|
|
2041
|
+
success: false,
|
|
2042
|
+
error: (0, n8n_errors_1.formatNoExecutionError)(),
|
|
2043
|
+
code: error.code
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
return {
|
|
2047
|
+
success: false,
|
|
2048
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2049
|
+
code: error.code,
|
|
2050
|
+
details: error.details
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
return {
|
|
2054
|
+
success: false,
|
|
2055
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
const community_package_service_1 = require("../services/community-package-service");
|
|
2060
|
+
function getCommunityPackageService(context, repository) {
|
|
2061
|
+
let apiUrl;
|
|
2062
|
+
let apiKey;
|
|
2063
|
+
if (context?.n8nApiUrl && context?.n8nApiKey) {
|
|
2064
|
+
apiUrl = context.n8nApiUrl;
|
|
2065
|
+
apiKey = context.n8nApiKey;
|
|
2066
|
+
}
|
|
2067
|
+
else {
|
|
2068
|
+
const config = (0, n8n_api_1.getN8nApiConfig)();
|
|
2069
|
+
if (config) {
|
|
2070
|
+
apiUrl = config.baseUrl;
|
|
2071
|
+
apiKey = config.apiKey || process.env.N8N_API_KEY;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
if (!apiUrl || !apiKey) {
|
|
2075
|
+
return null;
|
|
2076
|
+
}
|
|
2077
|
+
return new community_package_service_1.CommunityPackageService(apiUrl, apiKey, repository);
|
|
2078
|
+
}
|
|
2079
|
+
async function handleSearchCommunityNodes(args, repository, context) {
|
|
2080
|
+
const searchSchema = zod_1.z.object({
|
|
2081
|
+
query: zod_1.z.string().min(1, 'Query is required'),
|
|
2082
|
+
verifiedOnly: zod_1.z.boolean().optional().default(false),
|
|
2083
|
+
limit: zod_1.z.number().min(1).max(50).optional().default(20),
|
|
2084
|
+
});
|
|
2085
|
+
try {
|
|
2086
|
+
const input = searchSchema.parse(args);
|
|
2087
|
+
const service = getCommunityPackageService(context, repository);
|
|
2088
|
+
if (!service) {
|
|
2089
|
+
const fallbackService = new community_package_service_1.CommunityPackageService('', '', repository);
|
|
2090
|
+
const results = await fallbackService.searchCommunityNodes(input.query, {
|
|
2091
|
+
verifiedOnly: input.verifiedOnly,
|
|
2092
|
+
limit: input.limit,
|
|
2093
|
+
});
|
|
2094
|
+
return {
|
|
2095
|
+
success: true,
|
|
2096
|
+
data: {
|
|
2097
|
+
query: input.query,
|
|
2098
|
+
results,
|
|
2099
|
+
count: results.length,
|
|
2100
|
+
note: 'n8n API not configured. Results from local database and npm only.',
|
|
2101
|
+
},
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
const results = await service.searchCommunityNodes(input.query, {
|
|
2105
|
+
verifiedOnly: input.verifiedOnly,
|
|
2106
|
+
limit: input.limit,
|
|
2107
|
+
});
|
|
2108
|
+
return {
|
|
2109
|
+
success: true,
|
|
2110
|
+
data: {
|
|
2111
|
+
query: input.query,
|
|
2112
|
+
results,
|
|
2113
|
+
count: results.length,
|
|
2114
|
+
},
|
|
2115
|
+
message: `Found ${results.length} community node package(s) matching "${input.query}".`,
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
catch (error) {
|
|
2119
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2120
|
+
return {
|
|
2121
|
+
success: false,
|
|
2122
|
+
error: 'Invalid input',
|
|
2123
|
+
details: { errors: error.errors },
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
return {
|
|
2127
|
+
success: false,
|
|
2128
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
async function handleListCommunityPackages(args, context) {
|
|
2133
|
+
try {
|
|
2134
|
+
const service = getCommunityPackageService(context);
|
|
2135
|
+
if (!service) {
|
|
2136
|
+
return {
|
|
2137
|
+
success: false,
|
|
2138
|
+
error: 'n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.',
|
|
2139
|
+
};
|
|
2140
|
+
}
|
|
2141
|
+
const packages = await service.listInstalledPackages();
|
|
2142
|
+
const summary = {
|
|
2143
|
+
total: packages.length,
|
|
2144
|
+
withUpdates: packages.filter(p => p.updateAvailable).length,
|
|
2145
|
+
failedLoading: packages.filter(p => p.failedLoading).length,
|
|
2146
|
+
};
|
|
2147
|
+
return {
|
|
2148
|
+
success: true,
|
|
2149
|
+
data: {
|
|
2150
|
+
packages,
|
|
2151
|
+
summary,
|
|
2152
|
+
},
|
|
2153
|
+
message: packages.length > 0
|
|
2154
|
+
? `Found ${packages.length} installed community package(s).`
|
|
2155
|
+
: 'No community packages installed.',
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
catch (error) {
|
|
2159
|
+
return {
|
|
2160
|
+
success: false,
|
|
2161
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2162
|
+
};
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
async function handleInstallCommunityPackage(args, context) {
|
|
2166
|
+
const installSchema = zod_1.z.object({
|
|
2167
|
+
packageName: zod_1.z.string().min(1, 'Package name is required'),
|
|
2168
|
+
});
|
|
2169
|
+
try {
|
|
2170
|
+
const input = installSchema.parse(args);
|
|
2171
|
+
const service = getCommunityPackageService(context);
|
|
2172
|
+
if (!service) {
|
|
2173
|
+
return {
|
|
2174
|
+
success: false,
|
|
2175
|
+
error: 'n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.',
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
const result = await service.installPackage(input.packageName);
|
|
2179
|
+
return {
|
|
2180
|
+
success: true,
|
|
2181
|
+
data: result,
|
|
2182
|
+
message: result.message,
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
catch (error) {
|
|
2186
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2187
|
+
return {
|
|
2188
|
+
success: false,
|
|
2189
|
+
error: 'Invalid input',
|
|
2190
|
+
details: { errors: error.errors },
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
return {
|
|
2194
|
+
success: false,
|
|
2195
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
async function handleUninstallCommunityPackage(args, context) {
|
|
2200
|
+
const uninstallSchema = zod_1.z.object({
|
|
2201
|
+
packageName: zod_1.z.string().min(1, 'Package name is required'),
|
|
2202
|
+
});
|
|
2203
|
+
try {
|
|
2204
|
+
const input = uninstallSchema.parse(args);
|
|
2205
|
+
const service = getCommunityPackageService(context);
|
|
2206
|
+
if (!service) {
|
|
2207
|
+
return {
|
|
2208
|
+
success: false,
|
|
2209
|
+
error: 'n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.',
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
await service.uninstallPackage(input.packageName);
|
|
2213
|
+
return {
|
|
2214
|
+
success: true,
|
|
2215
|
+
message: `Successfully uninstalled "${input.packageName}". Note: You may need to restart n8n for changes to take effect.`,
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
catch (error) {
|
|
2219
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2220
|
+
return {
|
|
2221
|
+
success: false,
|
|
2222
|
+
error: 'Invalid input',
|
|
2223
|
+
details: { errors: error.errors },
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
return {
|
|
2227
|
+
success: false,
|
|
2228
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
async function handleUpdateCommunityPackage(args, context) {
|
|
2233
|
+
const updateSchema = zod_1.z.object({
|
|
2234
|
+
packageName: zod_1.z.string().min(1, 'Package name is required'),
|
|
2235
|
+
});
|
|
2236
|
+
try {
|
|
2237
|
+
const input = updateSchema.parse(args);
|
|
2238
|
+
const service = getCommunityPackageService(context);
|
|
2239
|
+
if (!service) {
|
|
2240
|
+
return {
|
|
2241
|
+
success: false,
|
|
2242
|
+
error: 'n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.',
|
|
2243
|
+
};
|
|
2244
|
+
}
|
|
2245
|
+
const result = await service.updatePackage(input.packageName);
|
|
2246
|
+
return {
|
|
2247
|
+
success: true,
|
|
2248
|
+
data: result,
|
|
2249
|
+
message: result.message,
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
catch (error) {
|
|
2253
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2254
|
+
return {
|
|
2255
|
+
success: false,
|
|
2256
|
+
error: 'Invalid input',
|
|
2257
|
+
details: { errors: error.errors },
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
return {
|
|
2261
|
+
success: false,
|
|
2262
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
const installed_node_sync_service_1 = require("../services/installed-node-sync-service");
|
|
2267
|
+
async function handleSyncInstalledNodes(args, repository, context) {
|
|
2268
|
+
const syncSchema = zod_1.z.object({
|
|
2269
|
+
cleanup: zod_1.z.boolean().optional().default(false),
|
|
2270
|
+
});
|
|
2271
|
+
try {
|
|
2272
|
+
let apiUrl;
|
|
2273
|
+
let apiKey;
|
|
2274
|
+
if (context?.n8nApiUrl && context?.n8nApiKey) {
|
|
2275
|
+
apiUrl = context.n8nApiUrl;
|
|
2276
|
+
apiKey = context.n8nApiKey;
|
|
2277
|
+
}
|
|
2278
|
+
else {
|
|
2279
|
+
const config = (0, n8n_api_1.getN8nApiConfig)();
|
|
2280
|
+
if (config) {
|
|
2281
|
+
apiUrl = config.baseUrl;
|
|
2282
|
+
apiKey = config.apiKey || process.env.N8N_API_KEY;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
if (!apiUrl || !apiKey) {
|
|
2286
|
+
return {
|
|
2287
|
+
success: false,
|
|
2288
|
+
error: 'n8n API not configured. Please set N8N_API_URL and N8N_API_KEY environment variables.',
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
const input = syncSchema.parse(args);
|
|
2292
|
+
const syncService = new installed_node_sync_service_1.InstalledNodeSyncService(apiUrl, apiKey, repository);
|
|
2293
|
+
const result = await syncService.syncInstalledNodes();
|
|
2294
|
+
let cleanedUp = 0;
|
|
2295
|
+
if (input.cleanup) {
|
|
2296
|
+
cleanedUp = await syncService.cleanupUninstalledNodes();
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
success: true,
|
|
2300
|
+
data: {
|
|
2301
|
+
...result,
|
|
2302
|
+
cleanedUp: input.cleanup ? cleanedUp : undefined,
|
|
2303
|
+
},
|
|
2304
|
+
message: result.nodesAdded > 0 || result.nodesUpdated > 0
|
|
2305
|
+
? `Synced ${result.nodesAdded} new nodes, updated ${result.nodesUpdated} existing nodes from ${result.packagesChecked} packages.`
|
|
2306
|
+
: `No new nodes to sync. ${result.packagesChecked} packages checked.`,
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
catch (error) {
|
|
2310
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2311
|
+
return {
|
|
2312
|
+
success: false,
|
|
2313
|
+
error: 'Invalid input',
|
|
2314
|
+
details: { errors: error.errors },
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
return {
|
|
2318
|
+
success: false,
|
|
2319
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
const listCredentialsSchema = zod_1.z.object({
|
|
2324
|
+
limit: zod_1.z.number().min(1).max(100).optional(),
|
|
2325
|
+
cursor: zod_1.z.string().optional(),
|
|
2326
|
+
});
|
|
2327
|
+
const getCredentialSchema = zod_1.z.object({
|
|
2328
|
+
id: zod_1.z.string(),
|
|
2329
|
+
});
|
|
2330
|
+
const createCredentialSchema = zod_1.z.object({
|
|
2331
|
+
name: zod_1.z.string().min(1, 'Credential name is required'),
|
|
2332
|
+
type: zod_1.z.string().min(1, 'Credential type is required'),
|
|
2333
|
+
data: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
2334
|
+
});
|
|
2335
|
+
const deleteCredentialSchema = zod_1.z.object({
|
|
2336
|
+
id: zod_1.z.string(),
|
|
2337
|
+
});
|
|
2338
|
+
const getCredentialTypesSchema = zod_1.z.object({
|
|
2339
|
+
filter: zod_1.z.string().optional(),
|
|
2340
|
+
});
|
|
2341
|
+
async function handleListCredentials(args, context) {
|
|
2342
|
+
try {
|
|
2343
|
+
const client = ensureApiConfigured(context);
|
|
2344
|
+
const input = listCredentialsSchema.parse(args);
|
|
2345
|
+
const response = await client.listCredentials({
|
|
2346
|
+
limit: input.limit || 50,
|
|
2347
|
+
cursor: input.cursor,
|
|
2348
|
+
});
|
|
2349
|
+
const sanitizedData = response.data.map(cred => ({
|
|
2350
|
+
id: cred.id,
|
|
2351
|
+
name: cred.name,
|
|
2352
|
+
type: cred.type,
|
|
2353
|
+
createdAt: cred.createdAt,
|
|
2354
|
+
updatedAt: cred.updatedAt,
|
|
2355
|
+
}));
|
|
2356
|
+
return {
|
|
2357
|
+
success: true,
|
|
2358
|
+
data: {
|
|
2359
|
+
credentials: sanitizedData,
|
|
2360
|
+
count: sanitizedData.length,
|
|
2361
|
+
nextCursor: response.nextCursor,
|
|
2362
|
+
hasMore: !!response.nextCursor,
|
|
2363
|
+
},
|
|
2364
|
+
message: `Found ${sanitizedData.length} credential(s).`,
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
catch (error) {
|
|
2368
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2369
|
+
return {
|
|
2370
|
+
success: false,
|
|
2371
|
+
error: 'Invalid input',
|
|
2372
|
+
details: { errors: error.errors },
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2376
|
+
return {
|
|
2377
|
+
success: false,
|
|
2378
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2379
|
+
code: error.code,
|
|
2380
|
+
details: error.details,
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
return {
|
|
2384
|
+
success: false,
|
|
2385
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
async function handleGetCredential(args, context) {
|
|
2390
|
+
try {
|
|
2391
|
+
const client = ensureApiConfigured(context);
|
|
2392
|
+
const input = getCredentialSchema.parse(args);
|
|
2393
|
+
const credential = await client.getCredential(input.id);
|
|
2394
|
+
const sanitizedData = {
|
|
2395
|
+
id: credential.id,
|
|
2396
|
+
name: credential.name,
|
|
2397
|
+
type: credential.type,
|
|
2398
|
+
createdAt: credential.createdAt,
|
|
2399
|
+
updatedAt: credential.updatedAt,
|
|
2400
|
+
nodesAccess: credential.nodesAccess,
|
|
2401
|
+
};
|
|
2402
|
+
return {
|
|
2403
|
+
success: true,
|
|
2404
|
+
data: sanitizedData,
|
|
2405
|
+
message: `Retrieved credential "${credential.name}".`,
|
|
2406
|
+
};
|
|
2407
|
+
}
|
|
2408
|
+
catch (error) {
|
|
2409
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2410
|
+
return {
|
|
2411
|
+
success: false,
|
|
2412
|
+
error: 'Invalid input',
|
|
2413
|
+
details: { errors: error.errors },
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2417
|
+
return {
|
|
2418
|
+
success: false,
|
|
2419
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2420
|
+
code: error.code,
|
|
2421
|
+
details: error.details,
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
return {
|
|
2425
|
+
success: false,
|
|
2426
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
async function handleCreateCredential(args, context) {
|
|
2431
|
+
try {
|
|
2432
|
+
const client = ensureApiConfigured(context);
|
|
2433
|
+
const input = createCredentialSchema.parse(args);
|
|
2434
|
+
const credential = await client.createCredential({
|
|
2435
|
+
name: input.name,
|
|
2436
|
+
type: input.type,
|
|
2437
|
+
data: input.data || {},
|
|
2438
|
+
});
|
|
2439
|
+
const sanitizedData = {
|
|
2440
|
+
id: credential.id,
|
|
2441
|
+
name: credential.name,
|
|
2442
|
+
type: credential.type,
|
|
2443
|
+
createdAt: credential.createdAt,
|
|
2444
|
+
};
|
|
2445
|
+
return {
|
|
2446
|
+
success: true,
|
|
2447
|
+
data: sanitizedData,
|
|
2448
|
+
message: `Credential "${credential.name}" created successfully.`,
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
catch (error) {
|
|
2452
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2453
|
+
return {
|
|
2454
|
+
success: false,
|
|
2455
|
+
error: 'Invalid input',
|
|
2456
|
+
details: { errors: error.errors },
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2460
|
+
return {
|
|
2461
|
+
success: false,
|
|
2462
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2463
|
+
code: error.code,
|
|
2464
|
+
details: error.details,
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
return {
|
|
2468
|
+
success: false,
|
|
2469
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
async function handleDeleteCredential(args, context) {
|
|
2474
|
+
try {
|
|
2475
|
+
const client = ensureApiConfigured(context);
|
|
2476
|
+
const input = deleteCredentialSchema.parse(args);
|
|
2477
|
+
await client.deleteCredential(input.id);
|
|
2478
|
+
return {
|
|
2479
|
+
success: true,
|
|
2480
|
+
message: `Credential deleted successfully. Workflows using this credential will need to be updated.`,
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
catch (error) {
|
|
2484
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2485
|
+
return {
|
|
2486
|
+
success: false,
|
|
2487
|
+
error: 'Invalid input',
|
|
2488
|
+
details: { errors: error.errors },
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2492
|
+
return {
|
|
2493
|
+
success: false,
|
|
2494
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2495
|
+
code: error.code,
|
|
2496
|
+
details: error.details,
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
return {
|
|
2500
|
+
success: false,
|
|
2501
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
async function handleGetCredentialTypes(args, repository, context) {
|
|
2506
|
+
try {
|
|
2507
|
+
const input = getCredentialTypesSchema.parse(args);
|
|
2508
|
+
const commonTypes = [
|
|
2509
|
+
{ name: 'httpBasicAuth', displayName: 'Basic Auth', description: 'HTTP Basic Authentication' },
|
|
2510
|
+
{ name: 'httpHeaderAuth', displayName: 'Header Auth', description: 'HTTP Header Authentication' },
|
|
2511
|
+
{ name: 'httpQueryAuth', displayName: 'Query Auth', description: 'HTTP Query String Authentication' },
|
|
2512
|
+
{ name: 'oAuth1Api', displayName: 'OAuth1 API', description: 'OAuth 1.0 Authentication' },
|
|
2513
|
+
{ name: 'oAuth2Api', displayName: 'OAuth2 API', description: 'OAuth 2.0 Authentication' },
|
|
2514
|
+
{ name: 'slackApi', displayName: 'Slack API', description: 'Slack API credentials' },
|
|
2515
|
+
{ name: 'googleApi', displayName: 'Google API', description: 'Google API OAuth2' },
|
|
2516
|
+
{ name: 'githubApi', displayName: 'GitHub API', description: 'GitHub API Token' },
|
|
2517
|
+
{ name: 'gitlabApi', displayName: 'GitLab API', description: 'GitLab API Token' },
|
|
2518
|
+
{ name: 'openAiApi', displayName: 'OpenAI API', description: 'OpenAI API Key' },
|
|
2519
|
+
{ name: 'anthropicApi', displayName: 'Anthropic API', description: 'Anthropic API Key' },
|
|
2520
|
+
];
|
|
2521
|
+
let filtered = commonTypes;
|
|
2522
|
+
if (input.filter) {
|
|
2523
|
+
const filterLower = input.filter.toLowerCase();
|
|
2524
|
+
filtered = commonTypes.filter(type => type.name.toLowerCase().includes(filterLower) ||
|
|
2525
|
+
type.displayName.toLowerCase().includes(filterLower) ||
|
|
2526
|
+
type.description.toLowerCase().includes(filterLower));
|
|
2527
|
+
}
|
|
2528
|
+
return {
|
|
2529
|
+
success: true,
|
|
2530
|
+
data: {
|
|
2531
|
+
types: filtered,
|
|
2532
|
+
count: filtered.length,
|
|
2533
|
+
note: 'This is a subset of common credential types. For node-specific credential requirements, use search_nodes to find the node and check its credential properties.',
|
|
2534
|
+
},
|
|
2535
|
+
message: input.filter
|
|
2536
|
+
? `Found ${filtered.length} credential type(s) matching "${input.filter}".`
|
|
2537
|
+
: `Found ${filtered.length} common credential type(s).`,
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
catch (error) {
|
|
2541
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2542
|
+
return {
|
|
2543
|
+
success: false,
|
|
2544
|
+
error: 'Invalid input',
|
|
2545
|
+
details: { errors: error.errors },
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
return {
|
|
2549
|
+
success: false,
|
|
2550
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
const listTagsSchema = zod_1.z.object({
|
|
2555
|
+
limit: zod_1.z.number().min(1).max(100).optional(),
|
|
2556
|
+
cursor: zod_1.z.string().optional(),
|
|
2557
|
+
withUsageCount: zod_1.z.boolean().optional(),
|
|
2558
|
+
});
|
|
2559
|
+
const createTagSchema = zod_1.z.object({
|
|
2560
|
+
name: zod_1.z.string().min(1, 'Tag name is required'),
|
|
2561
|
+
});
|
|
2562
|
+
const updateTagSchema = zod_1.z.object({
|
|
2563
|
+
id: zod_1.z.string(),
|
|
2564
|
+
name: zod_1.z.string().min(1, 'Tag name is required'),
|
|
2565
|
+
});
|
|
2566
|
+
const deleteTagSchema = zod_1.z.object({
|
|
2567
|
+
id: zod_1.z.string(),
|
|
2568
|
+
});
|
|
2569
|
+
const assignTagsSchema = zod_1.z.object({
|
|
2570
|
+
workflowId: zod_1.z.string(),
|
|
2571
|
+
tags: zod_1.z.array(zod_1.z.string()),
|
|
2572
|
+
});
|
|
2573
|
+
async function handleListTags(args, context) {
|
|
2574
|
+
try {
|
|
2575
|
+
const client = ensureApiConfigured(context);
|
|
2576
|
+
const input = listTagsSchema.parse(args);
|
|
2577
|
+
const response = await client.listTags({
|
|
2578
|
+
limit: input.limit || 100,
|
|
2579
|
+
cursor: input.cursor,
|
|
2580
|
+
withUsageCount: input.withUsageCount,
|
|
2581
|
+
});
|
|
2582
|
+
return {
|
|
2583
|
+
success: true,
|
|
2584
|
+
data: {
|
|
2585
|
+
tags: response.data,
|
|
2586
|
+
count: response.data.length,
|
|
2587
|
+
nextCursor: response.nextCursor,
|
|
2588
|
+
hasMore: !!response.nextCursor,
|
|
2589
|
+
},
|
|
2590
|
+
message: `Found ${response.data.length} tag(s).`,
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
catch (error) {
|
|
2594
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2595
|
+
return {
|
|
2596
|
+
success: false,
|
|
2597
|
+
error: 'Invalid input',
|
|
2598
|
+
details: { errors: error.errors },
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2602
|
+
return {
|
|
2603
|
+
success: false,
|
|
2604
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2605
|
+
code: error.code,
|
|
2606
|
+
details: error.details,
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
return {
|
|
2610
|
+
success: false,
|
|
2611
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
async function handleCreateTag(args, context) {
|
|
2616
|
+
try {
|
|
2617
|
+
const client = ensureApiConfigured(context);
|
|
2618
|
+
const input = createTagSchema.parse(args);
|
|
2619
|
+
const tag = await client.createTag({
|
|
2620
|
+
name: input.name,
|
|
2621
|
+
});
|
|
2622
|
+
return {
|
|
2623
|
+
success: true,
|
|
2624
|
+
data: {
|
|
2625
|
+
id: tag.id,
|
|
2626
|
+
name: tag.name,
|
|
2627
|
+
createdAt: tag.createdAt,
|
|
2628
|
+
},
|
|
2629
|
+
message: `Tag "${tag.name}" created successfully.`,
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
catch (error) {
|
|
2633
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2634
|
+
return {
|
|
2635
|
+
success: false,
|
|
2636
|
+
error: 'Invalid input',
|
|
2637
|
+
details: { errors: error.errors },
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2641
|
+
return {
|
|
2642
|
+
success: false,
|
|
2643
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2644
|
+
code: error.code,
|
|
2645
|
+
details: error.details,
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2648
|
+
return {
|
|
2649
|
+
success: false,
|
|
2650
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
async function handleUpdateTag(args, context) {
|
|
2655
|
+
try {
|
|
2656
|
+
const client = ensureApiConfigured(context);
|
|
2657
|
+
const input = updateTagSchema.parse(args);
|
|
2658
|
+
const tag = await client.updateTag(input.id, {
|
|
2659
|
+
name: input.name,
|
|
2660
|
+
});
|
|
2661
|
+
return {
|
|
2662
|
+
success: true,
|
|
2663
|
+
data: {
|
|
2664
|
+
id: tag.id,
|
|
2665
|
+
name: tag.name,
|
|
2666
|
+
updatedAt: tag.updatedAt,
|
|
2667
|
+
},
|
|
2668
|
+
message: `Tag updated to "${tag.name}".`,
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
catch (error) {
|
|
2672
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2673
|
+
return {
|
|
2674
|
+
success: false,
|
|
2675
|
+
error: 'Invalid input',
|
|
2676
|
+
details: { errors: error.errors },
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2680
|
+
return {
|
|
2681
|
+
success: false,
|
|
2682
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2683
|
+
code: error.code,
|
|
2684
|
+
details: error.details,
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
return {
|
|
2688
|
+
success: false,
|
|
2689
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
async function handleDeleteTag(args, context) {
|
|
2694
|
+
try {
|
|
2695
|
+
const client = ensureApiConfigured(context);
|
|
2696
|
+
const input = deleteTagSchema.parse(args);
|
|
2697
|
+
await client.deleteTag(input.id);
|
|
2698
|
+
return {
|
|
2699
|
+
success: true,
|
|
2700
|
+
message: `Tag deleted successfully. It has been removed from all workflows.`,
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
catch (error) {
|
|
2704
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2705
|
+
return {
|
|
2706
|
+
success: false,
|
|
2707
|
+
error: 'Invalid input',
|
|
2708
|
+
details: { errors: error.errors },
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2712
|
+
return {
|
|
2713
|
+
success: false,
|
|
2714
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2715
|
+
code: error.code,
|
|
2716
|
+
details: error.details,
|
|
2717
|
+
};
|
|
2718
|
+
}
|
|
2719
|
+
return {
|
|
2720
|
+
success: false,
|
|
2721
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
async function handleAssignTagsToWorkflow(args, context) {
|
|
2726
|
+
try {
|
|
2727
|
+
const client = ensureApiConfigured(context);
|
|
2728
|
+
const input = assignTagsSchema.parse(args);
|
|
2729
|
+
const workflow = await client.updateWorkflow(input.workflowId, {
|
|
2730
|
+
tags: input.tags,
|
|
2731
|
+
});
|
|
2732
|
+
return {
|
|
2733
|
+
success: true,
|
|
2734
|
+
data: {
|
|
2735
|
+
workflowId: workflow.id,
|
|
2736
|
+
workflowName: workflow.name,
|
|
2737
|
+
tags: workflow.tags || [],
|
|
2738
|
+
tagCount: (workflow.tags || []).length,
|
|
2739
|
+
},
|
|
2740
|
+
message: input.tags.length > 0
|
|
2741
|
+
? `Assigned ${input.tags.length} tag(s) to workflow "${workflow.name}".`
|
|
2742
|
+
: `Removed all tags from workflow "${workflow.name}".`,
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
catch (error) {
|
|
2746
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2747
|
+
return {
|
|
2748
|
+
success: false,
|
|
2749
|
+
error: 'Invalid input',
|
|
2750
|
+
details: { errors: error.errors },
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2754
|
+
return {
|
|
2755
|
+
success: false,
|
|
2756
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2757
|
+
code: error.code,
|
|
2758
|
+
details: error.details,
|
|
2759
|
+
};
|
|
2760
|
+
}
|
|
2761
|
+
return {
|
|
2762
|
+
success: false,
|
|
2763
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
const cloneWorkflowSchema = zod_1.z.object({
|
|
2768
|
+
workflowId: zod_1.z.string(),
|
|
2769
|
+
newName: zod_1.z.string().min(1, 'New workflow name is required'),
|
|
2770
|
+
activate: zod_1.z.boolean().optional(),
|
|
2771
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
2772
|
+
});
|
|
2773
|
+
const backupWorkflowsSchema = zod_1.z.object({
|
|
2774
|
+
active: zod_1.z.boolean().optional(),
|
|
2775
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
2776
|
+
includeCredentials: zod_1.z.boolean().optional(),
|
|
2777
|
+
});
|
|
2778
|
+
const restoreWorkflowSchema = zod_1.z.object({
|
|
2779
|
+
workflowData: zod_1.z.object({
|
|
2780
|
+
name: zod_1.z.string(),
|
|
2781
|
+
nodes: zod_1.z.array(zod_1.z.any()),
|
|
2782
|
+
connections: zod_1.z.record(zod_1.z.any()),
|
|
2783
|
+
}).passthrough(),
|
|
2784
|
+
mode: zod_1.z.enum(['create', 'update']).optional(),
|
|
2785
|
+
activate: zod_1.z.boolean().optional(),
|
|
2786
|
+
});
|
|
2787
|
+
async function handleCloneWorkflow(args, context) {
|
|
2788
|
+
try {
|
|
2789
|
+
const client = ensureApiConfigured(context);
|
|
2790
|
+
const input = cloneWorkflowSchema.parse(args);
|
|
2791
|
+
const sourceWorkflow = await client.getWorkflow(input.workflowId);
|
|
2792
|
+
const clonedWorkflow = await client.createWorkflow({
|
|
2793
|
+
name: input.newName,
|
|
2794
|
+
nodes: sourceWorkflow.nodes,
|
|
2795
|
+
connections: sourceWorkflow.connections,
|
|
2796
|
+
settings: sourceWorkflow.settings,
|
|
2797
|
+
staticData: {},
|
|
2798
|
+
tags: input.tags || sourceWorkflow.tags,
|
|
2799
|
+
});
|
|
2800
|
+
if (input.activate) {
|
|
2801
|
+
await client.updateWorkflow(clonedWorkflow.id, { active: true });
|
|
2802
|
+
}
|
|
2803
|
+
return {
|
|
2804
|
+
success: true,
|
|
2805
|
+
data: {
|
|
2806
|
+
id: clonedWorkflow.id,
|
|
2807
|
+
name: clonedWorkflow.name,
|
|
2808
|
+
sourceWorkflowId: input.workflowId,
|
|
2809
|
+
sourceWorkflowName: sourceWorkflow.name,
|
|
2810
|
+
active: input.activate || false,
|
|
2811
|
+
nodeCount: clonedWorkflow.nodes.length,
|
|
2812
|
+
},
|
|
2813
|
+
message: `Workflow "${sourceWorkflow.name}" cloned successfully as "${clonedWorkflow.name}".`,
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
catch (error) {
|
|
2817
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2818
|
+
return {
|
|
2819
|
+
success: false,
|
|
2820
|
+
error: 'Invalid input',
|
|
2821
|
+
details: { errors: error.errors },
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2825
|
+
return {
|
|
2826
|
+
success: false,
|
|
2827
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2828
|
+
code: error.code,
|
|
2829
|
+
details: error.details,
|
|
2830
|
+
};
|
|
2831
|
+
}
|
|
2832
|
+
return {
|
|
2833
|
+
success: false,
|
|
2834
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
async function handleBackupWorkflows(args, context) {
|
|
2839
|
+
try {
|
|
2840
|
+
const client = ensureApiConfigured(context);
|
|
2841
|
+
const input = backupWorkflowsSchema.parse(args);
|
|
2842
|
+
const response = await client.listWorkflows({
|
|
2843
|
+
active: input.active,
|
|
2844
|
+
tags: input.tags?.join(',') || undefined,
|
|
2845
|
+
limit: 100,
|
|
2846
|
+
});
|
|
2847
|
+
const workflows = response.data;
|
|
2848
|
+
const backupData = await Promise.all(workflows.map(async (wf) => {
|
|
2849
|
+
const fullWorkflow = await client.getWorkflow(wf.id);
|
|
2850
|
+
if (!input.includeCredentials) {
|
|
2851
|
+
fullWorkflow.nodes = fullWorkflow.nodes.map(node => {
|
|
2852
|
+
const { credentials, ...nodeWithoutCreds } = node;
|
|
2853
|
+
return nodeWithoutCreds;
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
return fullWorkflow;
|
|
2857
|
+
}));
|
|
2858
|
+
return {
|
|
2859
|
+
success: true,
|
|
2860
|
+
data: {
|
|
2861
|
+
workflows: backupData,
|
|
2862
|
+
count: backupData.length,
|
|
2863
|
+
timestamp: new Date().toISOString(),
|
|
2864
|
+
filters: {
|
|
2865
|
+
active: input.active,
|
|
2866
|
+
tags: input.tags,
|
|
2867
|
+
},
|
|
2868
|
+
},
|
|
2869
|
+
message: `Backed up ${backupData.length} workflow(s).`,
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2872
|
+
catch (error) {
|
|
2873
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2874
|
+
return {
|
|
2875
|
+
success: false,
|
|
2876
|
+
error: 'Invalid input',
|
|
2877
|
+
details: { errors: error.errors },
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2881
|
+
return {
|
|
2882
|
+
success: false,
|
|
2883
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2884
|
+
code: error.code,
|
|
2885
|
+
details: error.details,
|
|
2886
|
+
};
|
|
2887
|
+
}
|
|
2888
|
+
return {
|
|
2889
|
+
success: false,
|
|
2890
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
async function handleRestoreWorkflow(args, context) {
|
|
2895
|
+
try {
|
|
2896
|
+
const client = ensureApiConfigured(context);
|
|
2897
|
+
const input = restoreWorkflowSchema.parse(args);
|
|
2898
|
+
const mode = input.mode || 'create';
|
|
2899
|
+
let workflow;
|
|
2900
|
+
if (mode === 'update') {
|
|
2901
|
+
if (!input.workflowData.id) {
|
|
2902
|
+
return {
|
|
2903
|
+
success: false,
|
|
2904
|
+
error: 'Workflow ID is required for update mode',
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
workflow = await client.updateWorkflow(input.workflowData.id, {
|
|
2908
|
+
name: input.workflowData.name,
|
|
2909
|
+
nodes: input.workflowData.nodes,
|
|
2910
|
+
connections: input.workflowData.connections,
|
|
2911
|
+
settings: input.workflowData.settings,
|
|
2912
|
+
tags: input.workflowData.tags,
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
else {
|
|
2916
|
+
const { id, ...workflowWithoutId } = input.workflowData;
|
|
2917
|
+
workflow = await client.createWorkflow({
|
|
2918
|
+
name: workflowWithoutId.name,
|
|
2919
|
+
nodes: workflowWithoutId.nodes,
|
|
2920
|
+
connections: workflowWithoutId.connections,
|
|
2921
|
+
settings: workflowWithoutId.settings,
|
|
2922
|
+
tags: workflowWithoutId.tags,
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2925
|
+
if (input.activate && workflow.id) {
|
|
2926
|
+
await client.updateWorkflow(workflow.id, { active: true });
|
|
2927
|
+
}
|
|
2928
|
+
return {
|
|
2929
|
+
success: true,
|
|
2930
|
+
data: {
|
|
2931
|
+
id: workflow.id,
|
|
2932
|
+
name: workflow.name,
|
|
2933
|
+
mode,
|
|
2934
|
+
active: input.activate || false,
|
|
2935
|
+
nodeCount: workflow.nodes.length,
|
|
2936
|
+
},
|
|
2937
|
+
message: mode === 'create'
|
|
2938
|
+
? `Workflow "${workflow.name}" restored successfully.`
|
|
2939
|
+
: `Workflow "${workflow.name}" updated from backup.`,
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
catch (error) {
|
|
2943
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2944
|
+
return {
|
|
2945
|
+
success: false,
|
|
2946
|
+
error: 'Invalid input',
|
|
2947
|
+
details: { errors: error.errors },
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2951
|
+
return {
|
|
2952
|
+
success: false,
|
|
2953
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
2954
|
+
code: error.code,
|
|
2955
|
+
details: error.details,
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
return {
|
|
2959
|
+
success: false,
|
|
2960
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
const activateWorkflowSchema = zod_1.z.object({
|
|
2965
|
+
workflowId: zod_1.z.string(),
|
|
2966
|
+
});
|
|
2967
|
+
const deactivateWorkflowSchema = zod_1.z.object({
|
|
2968
|
+
workflowId: zod_1.z.string(),
|
|
2969
|
+
});
|
|
2970
|
+
const listActiveWorkflowsSchema = zod_1.z.object({
|
|
2971
|
+
limit: zod_1.z.number().min(1).max(100).optional(),
|
|
2972
|
+
cursor: zod_1.z.string().optional(),
|
|
2973
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
2974
|
+
});
|
|
2975
|
+
async function handleActivateWorkflow(args, context) {
|
|
2976
|
+
try {
|
|
2977
|
+
const client = ensureApiConfigured(context);
|
|
2978
|
+
const input = activateWorkflowSchema.parse(args);
|
|
2979
|
+
const workflow = await client.activateWorkflow(input.workflowId);
|
|
2980
|
+
return {
|
|
2981
|
+
success: true,
|
|
2982
|
+
data: {
|
|
2983
|
+
id: workflow.id,
|
|
2984
|
+
name: workflow.name,
|
|
2985
|
+
active: workflow.active,
|
|
2986
|
+
},
|
|
2987
|
+
message: `Workflow "${workflow.name}" activated successfully. Triggers are now enabled.`,
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
catch (error) {
|
|
2991
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
2992
|
+
return {
|
|
2993
|
+
success: false,
|
|
2994
|
+
error: 'Invalid input',
|
|
2995
|
+
details: { errors: error.errors },
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
2999
|
+
return {
|
|
3000
|
+
success: false,
|
|
3001
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3002
|
+
code: error.code,
|
|
3003
|
+
details: error.details,
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
return {
|
|
3007
|
+
success: false,
|
|
3008
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
async function handleDeactivateWorkflow(args, context) {
|
|
3013
|
+
try {
|
|
3014
|
+
const client = ensureApiConfigured(context);
|
|
3015
|
+
const input = deactivateWorkflowSchema.parse(args);
|
|
3016
|
+
const workflow = await client.deactivateWorkflow(input.workflowId);
|
|
3017
|
+
return {
|
|
3018
|
+
success: true,
|
|
3019
|
+
data: {
|
|
3020
|
+
id: workflow.id,
|
|
3021
|
+
name: workflow.name,
|
|
3022
|
+
active: workflow.active,
|
|
3023
|
+
},
|
|
3024
|
+
message: `Workflow "${workflow.name}" deactivated successfully. Triggers are now disabled.`,
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
catch (error) {
|
|
3028
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3029
|
+
return {
|
|
3030
|
+
success: false,
|
|
3031
|
+
error: 'Invalid input',
|
|
3032
|
+
details: { errors: error.errors },
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3036
|
+
return {
|
|
3037
|
+
success: false,
|
|
3038
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3039
|
+
code: error.code,
|
|
3040
|
+
details: error.details,
|
|
3041
|
+
};
|
|
3042
|
+
}
|
|
3043
|
+
return {
|
|
3044
|
+
success: false,
|
|
3045
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
async function handleListActiveWorkflows(args, context) {
|
|
3050
|
+
try {
|
|
3051
|
+
const client = ensureApiConfigured(context);
|
|
3052
|
+
const input = listActiveWorkflowsSchema.parse(args);
|
|
3053
|
+
const response = await client.listWorkflows({
|
|
3054
|
+
active: true,
|
|
3055
|
+
limit: input.limit || 100,
|
|
3056
|
+
cursor: input.cursor,
|
|
3057
|
+
tags: input.tags?.join(',') || undefined,
|
|
3058
|
+
});
|
|
3059
|
+
return {
|
|
3060
|
+
success: true,
|
|
3061
|
+
data: {
|
|
3062
|
+
workflows: response.data.map(wf => ({
|
|
3063
|
+
id: wf.id,
|
|
3064
|
+
name: wf.name,
|
|
3065
|
+
active: wf.active,
|
|
3066
|
+
tags: wf.tags,
|
|
3067
|
+
updatedAt: wf.updatedAt,
|
|
3068
|
+
})),
|
|
3069
|
+
count: response.data.length,
|
|
3070
|
+
nextCursor: response.nextCursor,
|
|
3071
|
+
hasMore: !!response.nextCursor,
|
|
3072
|
+
},
|
|
3073
|
+
message: `Found ${response.data.length} active workflow(s).`,
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
catch (error) {
|
|
3077
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3078
|
+
return {
|
|
3079
|
+
success: false,
|
|
3080
|
+
error: 'Invalid input',
|
|
3081
|
+
details: { errors: error.errors },
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3085
|
+
return {
|
|
3086
|
+
success: false,
|
|
3087
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3088
|
+
code: error.code,
|
|
3089
|
+
details: error.details,
|
|
3090
|
+
};
|
|
3091
|
+
}
|
|
3092
|
+
return {
|
|
3093
|
+
success: false,
|
|
3094
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
const workflow_analytics_service_1 = require("../services/workflow-analytics-service");
|
|
3099
|
+
const getWorkflowStatsSchema = zod_1.z.object({
|
|
3100
|
+
workflowId: zod_1.z.string(),
|
|
3101
|
+
daysBack: zod_1.z.number().min(1).max(90).optional(),
|
|
3102
|
+
});
|
|
3103
|
+
const getExecutionTrendsSchema = zod_1.z.object({
|
|
3104
|
+
workflowId: zod_1.z.string(),
|
|
3105
|
+
days: zod_1.z.number().min(1).max(30).optional(),
|
|
3106
|
+
});
|
|
3107
|
+
const getSlowWorkflowsSchema = zod_1.z.object({
|
|
3108
|
+
limit: zod_1.z.number().min(1).max(50).optional(),
|
|
3109
|
+
});
|
|
3110
|
+
async function handleGetWorkflowStats(args, context) {
|
|
3111
|
+
try {
|
|
3112
|
+
const client = ensureApiConfigured(context);
|
|
3113
|
+
const input = getWorkflowStatsSchema.parse(args);
|
|
3114
|
+
const analyticsService = new workflow_analytics_service_1.WorkflowAnalyticsService(client);
|
|
3115
|
+
const stats = await analyticsService.getWorkflowStats(input.workflowId, input.daysBack || 30);
|
|
3116
|
+
return {
|
|
3117
|
+
success: true,
|
|
3118
|
+
data: stats,
|
|
3119
|
+
message: `Analyzed ${stats.totalExecutions} execution(s) for workflow "${stats.workflowName}".`,
|
|
3120
|
+
};
|
|
3121
|
+
}
|
|
3122
|
+
catch (error) {
|
|
3123
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3124
|
+
return {
|
|
3125
|
+
success: false,
|
|
3126
|
+
error: 'Invalid input',
|
|
3127
|
+
details: { errors: error.errors },
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3131
|
+
return {
|
|
3132
|
+
success: false,
|
|
3133
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3134
|
+
code: error.code,
|
|
3135
|
+
details: error.details,
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
return {
|
|
3139
|
+
success: false,
|
|
3140
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
async function handleGetExecutionTrends(args, context) {
|
|
3145
|
+
try {
|
|
3146
|
+
const client = ensureApiConfigured(context);
|
|
3147
|
+
const input = getExecutionTrendsSchema.parse(args);
|
|
3148
|
+
const analyticsService = new workflow_analytics_service_1.WorkflowAnalyticsService(client);
|
|
3149
|
+
const trends = await analyticsService.getExecutionTrends(input.workflowId, input.days || 7);
|
|
3150
|
+
const totalExecutions = trends.reduce((sum, t) => sum + t.totalExecutions, 0);
|
|
3151
|
+
return {
|
|
3152
|
+
success: true,
|
|
3153
|
+
data: {
|
|
3154
|
+
trends,
|
|
3155
|
+
summary: {
|
|
3156
|
+
days: trends.length,
|
|
3157
|
+
totalExecutions,
|
|
3158
|
+
avgDailyExecutions: totalExecutions / trends.length,
|
|
3159
|
+
},
|
|
3160
|
+
},
|
|
3161
|
+
message: `Analyzed ${totalExecutions} execution(s) over ${trends.length} day(s).`,
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
catch (error) {
|
|
3165
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3166
|
+
return {
|
|
3167
|
+
success: false,
|
|
3168
|
+
error: 'Invalid input',
|
|
3169
|
+
details: { errors: error.errors },
|
|
3170
|
+
};
|
|
3171
|
+
}
|
|
3172
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3173
|
+
return {
|
|
3174
|
+
success: false,
|
|
3175
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3176
|
+
code: error.code,
|
|
3177
|
+
details: error.details,
|
|
3178
|
+
};
|
|
3179
|
+
}
|
|
3180
|
+
return {
|
|
3181
|
+
success: false,
|
|
3182
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3183
|
+
};
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
async function handleGetSlowWorkflows(args, context) {
|
|
3187
|
+
try {
|
|
3188
|
+
const client = ensureApiConfigured(context);
|
|
3189
|
+
const input = getSlowWorkflowsSchema.parse(args);
|
|
3190
|
+
const analyticsService = new workflow_analytics_service_1.WorkflowAnalyticsService(client);
|
|
3191
|
+
const slowWorkflows = await analyticsService.getSlowWorkflows(input.limit || 10);
|
|
3192
|
+
return {
|
|
3193
|
+
success: true,
|
|
3194
|
+
data: {
|
|
3195
|
+
workflows: slowWorkflows,
|
|
3196
|
+
count: slowWorkflows.length,
|
|
3197
|
+
},
|
|
3198
|
+
message: `Found ${slowWorkflows.length} workflow(s) sorted by execution time.`,
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
catch (error) {
|
|
3202
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3203
|
+
return {
|
|
3204
|
+
success: false,
|
|
3205
|
+
error: 'Invalid input',
|
|
3206
|
+
details: { errors: error.errors },
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3210
|
+
return {
|
|
3211
|
+
success: false,
|
|
3212
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3213
|
+
code: error.code,
|
|
3214
|
+
details: error.details,
|
|
3215
|
+
};
|
|
3216
|
+
}
|
|
3217
|
+
return {
|
|
3218
|
+
success: false,
|
|
3219
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3220
|
+
};
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
const workflow_debugging_service_1 = require("../services/workflow-debugging-service");
|
|
3224
|
+
const traceExecutionSchema = zod_1.z.object({
|
|
3225
|
+
executionId: zod_1.z.string(),
|
|
3226
|
+
});
|
|
3227
|
+
const compareExecutionsSchema = zod_1.z.object({
|
|
3228
|
+
executionId1: zod_1.z.string(),
|
|
3229
|
+
executionId2: zod_1.z.string(),
|
|
3230
|
+
});
|
|
3231
|
+
async function handleTraceExecution(args, context) {
|
|
3232
|
+
try {
|
|
3233
|
+
const client = ensureApiConfigured(context);
|
|
3234
|
+
const input = traceExecutionSchema.parse(args);
|
|
3235
|
+
const debugService = new workflow_debugging_service_1.WorkflowDebuggingService(client);
|
|
3236
|
+
const trace = await debugService.traceExecution(input.executionId);
|
|
3237
|
+
return {
|
|
3238
|
+
success: true,
|
|
3239
|
+
data: trace,
|
|
3240
|
+
message: `Traced execution: ${trace.summary.executedNodes}/${trace.summary.totalNodes} nodes executed, status: ${trace.status}`,
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
catch (error) {
|
|
3244
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3245
|
+
return {
|
|
3246
|
+
success: false,
|
|
3247
|
+
error: 'Invalid input',
|
|
3248
|
+
details: { errors: error.errors },
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3251
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3252
|
+
return {
|
|
3253
|
+
success: false,
|
|
3254
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3255
|
+
code: error.code,
|
|
3256
|
+
details: error.details,
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
return {
|
|
3260
|
+
success: false,
|
|
3261
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
async function handleCompareExecutions(args, context) {
|
|
3266
|
+
try {
|
|
3267
|
+
const client = ensureApiConfigured(context);
|
|
3268
|
+
const input = compareExecutionsSchema.parse(args);
|
|
3269
|
+
const debugService = new workflow_debugging_service_1.WorkflowDebuggingService(client);
|
|
3270
|
+
const comparison = await debugService.compareExecutions(input.executionId1, input.executionId2);
|
|
3271
|
+
return {
|
|
3272
|
+
success: true,
|
|
3273
|
+
data: comparison,
|
|
3274
|
+
message: `Found ${comparison.differences.length} difference(s) between executions`,
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
catch (error) {
|
|
3278
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
3279
|
+
return {
|
|
3280
|
+
success: false,
|
|
3281
|
+
error: 'Invalid input',
|
|
3282
|
+
details: { errors: error.errors },
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
if (error instanceof n8n_errors_1.N8nApiError) {
|
|
3286
|
+
return {
|
|
3287
|
+
success: false,
|
|
3288
|
+
error: (0, n8n_errors_1.getUserFriendlyErrorMessage)(error),
|
|
3289
|
+
code: error.code,
|
|
3290
|
+
details: error.details,
|
|
3291
|
+
};
|
|
3292
|
+
}
|
|
3293
|
+
return {
|
|
3294
|
+
success: false,
|
|
3295
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
3296
|
+
};
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
//# sourceMappingURL=handlers-n8n-manager.js.map
|