/** * Workflow Editor Helper * Contains business logic for workflow operations */ import type { WorkflowNode as WorkflowNodeType, NodeMetadata, Workflow, WorkflowEdge, NodeExecutionInfo } from '../types/index.js'; import type { EndpointConfig } from '../config/endpoints.js'; /** * Generate a unique node ID based on node type and existing nodes * Format: . * Example: boolean_gateway.1, calculator.2 */ export declare function generateNodeId(nodeTypeId: string, existingNodes: WorkflowNodeType[]): string; /** * Edge category type for styling purposes * - trigger: For control flow connections (dataType: "trigger") * - tool: Dashed amber line for tool connections (dataType: "tool") * - loopback: Dashed gray line for loop iteration connections (targets loop_back port) * - data: Normal gray line for all other data connections */ export type EdgeCategory = 'trigger' | 'tool' | 'loopback' | 'data'; /** * Edge styling configuration based on source port data type */ export declare class EdgeStylingHelper { /** * Extract the port ID from a handle ID * @param handleId - The handle ID string (e.g., "sample-node.1-output-trigger" or "trigger") * @returns The port ID (e.g., "trigger") or the handleId itself for short format */ static extractPortIdFromHandle(handleId: string | undefined): string | null; /** * Check if a port ID matches a dynamic branch in a Gateway node * Gateway nodes store branches in config.branches array * @param node - The workflow node to check * @param portId - The port ID to look up * @returns true if the portId matches a gateway branch */ static isGatewayBranch(node: WorkflowNodeType, portId: string): boolean; /** * Get the data type of a port from a node's metadata * Also handles dynamic ports like Gateway branches * @param node - The workflow node containing the port * @param portId - The port ID to look up * @param portType - Whether to look in "inputs" or "outputs" * @returns The port's dataType or null if not found */ static getPortDataType(node: WorkflowNodeType, portId: string, portType: 'input' | 'output'): string | null; /** * Determine the edge category based on source port data type * Note: This method does not check for loopback edges. * Use getEdgeCategoryWithLoopback() for full edge categorization. * * @param sourcePortDataType - The data type of the source output port * @returns The edge category for styling */ static getEdgeCategory(sourcePortDataType: string | null): EdgeCategory; /** * Determine the full edge category including loopback detection * Loopback edges take precedence over source port data type * * @param edge - The edge to categorize * @param sourcePortDataType - The data type of the source output port * @returns The edge category for styling */ static getEdgeCategoryWithLoopback(edge: WorkflowEdge, sourcePortDataType: string | null): EdgeCategory; /** * Apply custom styling to connection edges based on edge type: * - Loopback: Dashed gray line for loop iteration (targets loop_back port) * - Trigger ports: Solid black line with arrow * - Tool ports: Dashed amber line with arrow * - Data ports: Normal gray line with arrow */ static applyConnectionStyling(edge: WorkflowEdge, sourceNode: WorkflowNodeType, targetNode: WorkflowNodeType): void; /** * Update existing edges with custom styling rules */ static updateEdgeStyles(edges: WorkflowEdge[], nodes: WorkflowNodeType[]): WorkflowEdge[]; } /** * Node operations helper */ export declare class NodeOperationsHelper { /** * Load nodes from API */ static loadNodesFromApi(providedNodes?: NodeMetadata[]): Promise; /** * Load node execution information for all nodes in the workflow */ static loadNodeExecutionInfo(workflow: Workflow | null, pipelineId?: string): Promise>; /** * Create a new node from dropped data */ static createNodeFromDrop(nodeTypeData: string, position: { x: number; y: number; }, existingNodes?: WorkflowNodeType[]): WorkflowNodeType | null; } /** * Workflow operations helper */ export declare class WorkflowOperationsHelper { /** * Generate workflow metadata for updates */ static generateMetadata(existingMetadata?: Workflow['metadata']): Workflow['metadata']; /** * Update workflow with new nodes/edges and generate new metadata */ static updateWorkflow(workflow: Workflow, nodes: WorkflowNodeType[], edges: WorkflowEdge[]): Workflow; /** * Clear workflow (remove all nodes and edges) */ static clearWorkflow(workflow: Workflow): Workflow; /** * Update node configuration */ static updateNodeConfig(workflow: Workflow, nodeId: string, newConfig: Record): Workflow; /** * Add a new node to the workflow */ static addNode(workflow: Workflow, node: WorkflowNodeType): Workflow; /** * Save workflow to backend */ static saveWorkflow(workflow: Workflow | null): Promise; /** * Export workflow as JSON file */ static exportWorkflow(workflow: Workflow | null): void; /** * Export workflow as Agent Spec JSON file. * * Converts the FlowDrop workflow to Agent Spec format and triggers a download. * Validates the workflow for Agent Spec compatibility first. * * @param workflow - The FlowDrop workflow to export * @returns Validation result (check .valid before assuming success) */ static exportAsAgentSpec(workflow: Workflow | null): { valid: boolean; errors: string[]; warnings: string[]; }; /** * Import a workflow from an Agent Spec JSON or YAML file. * * Reads the file, detects format, converts to FlowDrop format, * and returns a Workflow ready for the editor. * * @param file - The file to import (JSON or YAML) * @returns Promise resolving to the imported FlowDrop Workflow */ static importFromAgentSpec(file: File): Promise; /** * Check if workflow has invalid cycles (excludes valid loopback cycles) * Valid loopback cycles are used for ForEach node iteration and should not * trigger a warning. * * @param nodes - Array of workflow nodes * @param edges - Array of workflow edges * @returns True if there are invalid (non-loopback) cycles */ static checkWorkflowCycles(nodes: WorkflowNodeType[], edges: WorkflowEdge[]): boolean; /** * Check if workflow has any cycles (including valid loopback cycles) * Use this when you need to detect ALL cycles regardless of type. * * @param nodes - Array of workflow nodes * @param edges - Array of workflow edges * @returns True if any cycle exists */ static checkWorkflowHasAnyCycles(nodes: WorkflowNodeType[], edges: WorkflowEdge[]): boolean; } /** * Configuration helper */ export declare class ConfigurationHelper { /** * Configure API endpoints */ static configureEndpoints(config: EndpointConfig): void; }