Files
Agent-n8n/n8n-n8n-1.109.2/packages/workflow/src/tool-helpers.ts
2025-09-08 04:48:28 +08:00

11 lines
427 B
TypeScript
Executable File

import type { INode } from './interfaces';
/**
* Converts a node name to a valid tool name by replacing special characters with underscores
* and collapsing consecutive underscores into a single one.
*/
export function nodeNameToToolName(nodeOrName: INode | string): string {
const name = typeof nodeOrName === 'string' ? nodeOrName : nodeOrName.name;
return name.replace(/[\s.?!=+#@&*()[\]{}:;,<>\/\\'"^%$_]+/g, '_');
}