diff --git a/lib/workflow.ts b/lib/workflow.ts deleted file mode 100644 index b60b153d83..0000000000 --- a/lib/workflow.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Edge } from 'reactflow' -import { BlockState } from '@/stores/workflow/types' -import { Executor } from '@/executor' -import { Serializer } from '@/serializer' - -export interface WorkflowExecutionResult { - success: boolean - output?: Record - error?: string -} - -/** - * Executes a workflow with the given blocks and edges - * @param blocks - The blocks in the workflow - * @param edges - The connections between blocks - * @param workflowId - The ID of the workflow - * @returns A promise that resolves to the workflow execution result - */ -export async function executeWorkflow( - blocks: Record, - edges: Edge[], - workflowId: string -): Promise { - try { - // 1. Serialize the workflow - const serializer = new Serializer() - const serializedWorkflow = serializer.serializeWorkflow(blocks, edges) - - // 2. Create executor and run workflow - const executor = new Executor(serializedWorkflow) - const result = await executor.execute(workflowId) - - // 3. Return result - if (result.success) { - console.log('Workflow executed successfully:', result.output) - return { - success: true, - output: result.output, - } - } else { - console.error('Workflow execution failed:', result.error) - return { - success: false, - error: result.error, - } - } - } catch (error: any) { - console.error('Error executing workflow:', error) - return { - success: false, - error: error instanceof Error ? error.message : 'Unknown error occurred', - } - } -}