/** * 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'; export { generateNodeId, extractConfigDefaults } from '../utils/nodeIds.js'; /** * 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. * Delegates to standalone functions in utils/edgeStyling.ts. */ export declare class EdgeStylingHelper { static extractPortIdFromHandle(handleId: string | undefined): string | null; static isGatewayBranch(node: WorkflowNodeType, portId: string): boolean; static getPortDataType(node: WorkflowNodeType, portId: string, portType: 'input' | 'output'): string | null; static getEdgeCategory(sourcePortDataType: string | null): EdgeCategory; static getEdgeCategoryWithLoopback(edge: WorkflowEdge, sourcePortDataType: string | null): EdgeCategory; static applyConnectionStyling(edge: WorkflowEdge, sourceNode: WorkflowNodeType, targetNode: WorkflowNodeType): void; 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; }