mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
Deleted lib file unused
This commit is contained in:
@@ -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<string, any>
|
||||
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<string, BlockState>,
|
||||
edges: Edge[],
|
||||
workflowId: string
|
||||
): Promise<WorkflowExecutionResult> {
|
||||
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',
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user