Files
n8n-mcp/dist/services/workflow-auto-fixer.d.ts
czlonkowski 2e472ebc6c feat(auto-fixer): add 5 connection structure fix types
Add automatic repair for malformed workflow connections commonly
generated by AI models:
- connection-numeric-keys: "0","1" keys → main[0], main[1]
- connection-invalid-type: type:"0" → type:"main" (or parent key)
- connection-id-to-name: node ID refs → node name refs
- connection-duplicate-removal: dedup identical connection entries
- connection-input-index: out-of-bounds input index → clamped

Includes collision-safe ID-to-name renames, medium confidence on
merge conflicts and index clamping, shared CONNECTION_FIX_TYPES
constant, and 24 unit tests.

Concieved by Romuald Członkowski - www.aiadvisors.pl/en

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 07:17:40 +01:00

81 lines
3.0 KiB
TypeScript

import { WorkflowValidationResult } from './workflow-validator';
import { ExpressionFormatIssue } from './expression-format-validator';
import { NodeRepository } from '../database/node-repository';
import { WorkflowDiffOperation } from '../types/workflow-diff';
import { Workflow } from '../types/n8n-api';
import { PostUpdateGuidance } from './post-update-validator';
export type FixConfidenceLevel = 'high' | 'medium' | 'low';
export type FixType = 'expression-format' | 'typeversion-correction' | 'error-output-config' | 'node-type-correction' | 'webhook-missing-path' | 'typeversion-upgrade' | 'version-migration' | 'tool-variant-correction' | 'connection-numeric-keys' | 'connection-invalid-type' | 'connection-id-to-name' | 'connection-duplicate-removal' | 'connection-input-index';
export declare const CONNECTION_FIX_TYPES: FixType[];
export interface AutoFixConfig {
applyFixes: boolean;
fixTypes?: FixType[];
confidenceThreshold?: FixConfidenceLevel;
maxFixes?: number;
}
export interface FixOperation {
node: string;
field: string;
type: FixType;
before: any;
after: any;
confidence: FixConfidenceLevel;
description: string;
}
export interface AutoFixResult {
operations: WorkflowDiffOperation[];
fixes: FixOperation[];
summary: string;
stats: {
total: number;
byType: Record<FixType, number>;
byConfidence: Record<FixConfidenceLevel, number>;
};
postUpdateGuidance?: PostUpdateGuidance[];
}
export interface NodeFormatIssue extends ExpressionFormatIssue {
nodeName: string;
nodeId: string;
}
export declare function isNodeFormatIssue(issue: ExpressionFormatIssue): issue is NodeFormatIssue;
export interface NodeTypeError {
type: 'error';
nodeId?: string;
nodeName?: string;
message: string;
suggestions?: Array<{
nodeType: string;
confidence: number;
reason: string;
}>;
}
export declare class WorkflowAutoFixer {
private readonly defaultConfig;
private similarityService;
private versionService;
private breakingChangeDetector;
private migrationService;
private postUpdateValidator;
constructor(repository?: NodeRepository);
generateFixes(workflow: Workflow, validationResult: WorkflowValidationResult, formatIssues?: ExpressionFormatIssue[], config?: Partial<AutoFixConfig>): Promise<AutoFixResult>;
private processExpressionFormatFixes;
private processTypeVersionFixes;
private processErrorOutputFixes;
private processNodeTypeFixes;
private processWebhookPathFixes;
private processToolVariantFixes;
private setNestedValue;
private filterByConfidence;
private filterOperationsByFixes;
private calculateStats;
private generateSummary;
private processConnectionFixes;
private fixNumericKeys;
private fixIdToName;
private fixInvalidTypes;
private fixInputIndices;
private fixDuplicateConnections;
private processVersionUpgradeFixes;
private processVersionMigrationFixes;
}
//# sourceMappingURL=workflow-auto-fixer.d.ts.map