@@ -66,6 +66,8 @@ import type {
6666 TryNode ,
6767 WaitConfig ,
6868 WorkflowFile ,
69+ WorkflowInput ,
70+ WorkflowSchema ,
6971} from './model' ;
7072import { ZIGFLOW_ID_KEY } from './model' ;
7173
@@ -121,6 +123,20 @@ export function parseWorkflowFile(
121123
122124 const doEntries = ( raw [ 'do' ] as RawEntry [ ] ) ?? [ ] ;
123125
126+ // Parse input.schema — default when absent.
127+ const rawInput = raw [ 'input' ] as Record < string , unknown > | undefined ;
128+ const rawSchema = rawInput ?. [ 'schema' ] as Record < string , unknown > | undefined ;
129+ const schema : WorkflowSchema = rawSchema
130+ ? {
131+ format : String ( rawSchema [ 'format' ] ?? 'json' ) ,
132+ document : ( rawSchema [ 'document' ] ?? {
133+ type : 'object' ,
134+ properties : { } ,
135+ } ) as Record < string , unknown > ,
136+ }
137+ : { format : 'json' , document : { type : 'object' , properties : { } } } ;
138+ const input : WorkflowInput = { schema } ;
139+
124140 const ctx : ParseCtx = { modified : false , newFormat : false } ;
125141
126142 // Detect format: new format if every entry's value has a `do:` key.
@@ -133,12 +149,12 @@ export function parseWorkflowFile(
133149
134150 if ( isNewFormat ) {
135151 ctx . newFormat = true ;
136- const workflowFile = parseNewFormat ( doEntries , document , ctx ) ;
152+ const workflowFile = parseNewFormat ( doEntries , document , input , ctx ) ;
137153 return { workflowFile, modified : ctx . modified } ;
138154 }
139155
140156 // Old format: flat steps with hoisted sub-graph entries.
141- return parseOldFormat ( doEntries , document , ctx ) ;
157+ return parseOldFormat ( doEntries , document , input , ctx ) ;
142158}
143159
144160// ---------------------------------------------------------------------------
@@ -154,6 +170,7 @@ export function parseWorkflowFile(
154170function parseNewFormat (
155171 doEntries : RawEntry [ ] ,
156172 document : DocumentMetadata ,
173+ input : WorkflowInput ,
157174 ctx : ParseCtx ,
158175) : WorkflowFile {
159176 const workflows : Record < string , NamedWorkflow > = { } ;
@@ -182,7 +199,7 @@ function parseNewFormat(
182199 order . push ( id ) ;
183200 }
184201
185- return { document, workflows, order } ;
202+ return { document, input , workflows, order } ;
186203}
187204
188205// ---------------------------------------------------------------------------
@@ -196,6 +213,7 @@ function parseNewFormat(
196213function parseOldFormat (
197214 doEntries : RawEntry [ ] ,
198215 document : DocumentMetadata ,
216+ input : WorkflowInput ,
199217 ctx : ParseCtx ,
200218) : ParseResult {
201219 // Build a flat map of all named entries for hoisted branch resolution.
@@ -220,6 +238,7 @@ function parseOldFormat(
220238
221239 const workflowFile : WorkflowFile = {
222240 document,
241+ input,
223242 workflows : { [ workflowId ] : workflow } ,
224243 order : [ workflowId ] ,
225244 } ;
0 commit comments