fix: recognize dynamic AI Tool nodes in validator (Issue #522) (#526)

When n8n connects any node to an AI Agent's tool slot, it creates a
dynamic Tool variant at runtime (e.g., googleDrive → googleDriveTool).
These don't exist in npm packages, causing false "unknown node type"
errors.

Added validation-time inference: when a *Tool node type is not found,
check if the base node exists. If yes, treat as valid with warning.

Changes:
- workflow-validator.ts: Add INFERRED_TOOL_VARIANT logic
- node-similarity-service.ts: Add 98% confidence for valid Tool variants
- Added 7 unit tests for inferred tool variant functionality

Fixes #522

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Romuald Członkowski <romualdczlonkowski@MacBook-Pro-Romuald.local>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Romuald Członkowski
2026-01-07 18:09:55 +01:00
committed by GitHub
parent 861005eeed
commit ce2c94c1a5
11 changed files with 425 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
import { NodeRepository } from '../database/node-repository';
import { logger } from '../utils/logger';
import { ToolVariantGenerator } from './tool-variant-generator';
export interface NodeSuggestion {
nodeType: string;
@@ -126,6 +127,25 @@ export class NodeSimilarityService {
return [];
}
// Check if this is a Tool variant and base node exists (Issue #522)
// Dynamic AI Tool variants like googleDriveTool are created at runtime by n8n
if (ToolVariantGenerator.isToolVariantNodeType(invalidType)) {
const baseNodeType = ToolVariantGenerator.getBaseNodeType(invalidType);
if (baseNodeType) {
const baseNode = this.repository.getNode(baseNodeType);
if (baseNode) {
return [{
nodeType: invalidType,
displayName: `${baseNode.displayName} Tool`,
confidence: 0.98,
reason: `Dynamic AI Tool variant of ${baseNode.displayName}`,
category: baseNode.category,
description: 'Runtime-generated Tool variant for AI Agent integration'
}];
}
}
}
const suggestions: NodeSuggestion[] = [];
// First, check for exact common mistakes