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

Function extractModulePaths

yaml-flow-editor/src/utils/collectModules.ts:55–111  ·  view source on GitHub ↗
(steps: WorkflowStep[])

Source from the content-addressed store, hash-verified

53
54 // Extract module paths from a list of workflow steps
55 function extractModulePaths(steps: WorkflowStep[]): string[] {
56 const paths: string[] = [];
57 for (const step of steps) {
58 if ('call' in step && step.call) {
59 const c = step.call as { module?: string };
60 if (c.module) paths.push(c.module);
61 }
62 if ('parallel' in step && step.parallel) {
63 const p = step.parallel as { module?: string };
64 if (p.module) paths.push(p.module);
65 }
66 if ('gather' in step && step.gather) {
67 const g = step.gather as {
68 module?: string;
69 calls?: Array<{ module?: string }>;
70 };
71 // Format 2: single module
72 if (g.module) paths.push(g.module);
73 // Format 1: calls array
74 if (g.calls) {
75 for (const call of g.calls) {
76 if (call.module) paths.push(call.module);
77 }
78 }
79 }
80 // Recurse into control flow bodies
81 if ('if' in step && step.if) {
82 const ifData = step.if as {
83 then?: WorkflowStep[];
84 else?: WorkflowStep[];
85 };
86 if (ifData.then) paths.push(...extractModulePaths(ifData.then));
87 if (ifData.else) paths.push(...extractModulePaths(ifData.else));
88 }
89 if ('while' in step && step.while) {
90 const w = step.while as { steps?: WorkflowStep[] };
91 if (w.steps) paths.push(...extractModulePaths(w.steps));
92 }
93 if ('for_each' in step && step.for_each) {
94 const f = step.for_each as { steps?: WorkflowStep[] };
95 if (f.steps) paths.push(...extractModulePaths(f.steps));
96 }
97 if ('switch' in step && step.switch) {
98 const s = step.switch as {
99 cases?: Record<string, WorkflowStep[]>;
100 default?: WorkflowStep[];
101 };
102 if (s.cases) {
103 for (const body of Object.values(s.cases)) {
104 if (Array.isArray(body)) paths.push(...extractModulePaths(body));
105 }
106 }
107 if (s.default) paths.push(...extractModulePaths(s.default));
108 }
109 }
110 return paths;
111 }
112

Callers 1

processFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected