MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / processWorkflowStep

Function processWorkflowStep

yaml-flow-editor/src/converters/yaml-to-graph.ts:80–334  ·  view source on GitHub ↗
(
  ctx: ConversionContext,
  step: WorkflowStep,
  baseX: number,
  baseY: number
)

Source from the content-addressed store, hash-verified

78}
79
80function processWorkflowStep(
81 ctx: ConversionContext,
82 step: WorkflowStep,
83 baseX: number,
84 baseY: number
85): { node: FlowNode; endY: number } {
86
87 if ('step' in step) {
88 const stepData = step.step as StepData;
89 const nodeData: Record<string, unknown> = {
90 label: stepData.name ?? 'Step',
91 nodeType: 'step',
92 name: stepData.name ?? '',
93 };
94 // Optional fields: include only when present in YAML, converting null → ''
95 if (stepData.instruction !== undefined) nodeData.instruction = stepData.instruction ?? '';
96 if (stepData.save_as !== undefined) nodeData.save_as = stepData.save_as ?? '';
97 if (stepData.output_file !== undefined) nodeData.output_file = stepData.output_file ?? '';
98 if (stepData.enabled_tools !== undefined) nodeData.enabled_tools = stepData.enabled_tools;
99
100 const node = createNode(ctx, 'step', nodeData as FlowNodeData, { x: baseX, y: baseY });
101 return { node, endY: baseY + NODE_SPACING_Y };
102 }
103
104 if ('if' in step) {
105 const ifData = step.if as IfData;
106 const condition = normalizeValue(ifData.condition, 'true');
107
108 const thenSteps = ifData.then?.length
109 ? workflowStepsToFlowNodeData(ifData.then)
110 : [];
111 const elseSteps = ifData.else?.length
112 ? workflowStepsToFlowNodeData(ifData.else)
113 : [];
114
115 const ifNode = createNode(ctx, 'if', {
116 label: `If: ${condition.substring(0, 20)}${condition.length > 20 ? '...' : ''}`,
117 nodeType: 'if',
118 condition,
119 thenSteps,
120 elseSteps,
121 } as FlowNodeData, { x: baseX, y: baseY });
122
123 return { node: ifNode, endY: baseY + NODE_SPACING_Y };
124 }
125
126 if ('while' in step) {
127 const whileData = step.while as WhileData;
128 const condition = normalizeValue(whileData.condition, 'true');
129
130 const loopSteps = whileData.steps?.length
131 ? workflowStepsToFlowNodeData(whileData.steps)
132 : [];
133
134 const whileNode = createNode(ctx, 'while', {
135 label: `While: ${condition.substring(0, 15)}${condition.length > 15 ? '...' : ''}`,
136 nodeType: 'while',
137 condition,

Callers 1

processWorkflowSequenceFunction · 0.85

Calls 5

normalizeValueFunction · 0.90
normalizeObjectFunction · 0.90
createNodeFunction · 0.85
assignDefinedFunction · 0.85

Tested by

no test coverage detected