Skip to main content

Type Alias: InferWorkflowContext<W>

InferWorkflowContext<W> = W extends Workflow<any, any, infer C> ? C : never

Defined in: packages/workflow-engine/src/core/workflow.ts:1055

Extract the workflow context type from a Workflow instance

The workflow context type is automatically accumulated as stages are piped. Each stage's output is added to the context under its stage ID.

Type Parameters​

W​

W

Example​

const workflow = new WorkflowBuilder(...)
.pipe(dataExtractionStage) // id: "data-extraction"
.pipe(guidelinesStage) // id: "guidelines"
.build();

// Extract context type automatically
type MyWorkflowContext = InferWorkflowContext<typeof workflow>;
// = {
// "data-extraction": DataExtractionOutput;
// "guidelines": GuidelinesOutput;
// }

// Use in stage definitions
export const myStage = defineStage<
"my-stage-id",
"none",
typeof OutputSchema,
typeof ConfigSchema,
MyWorkflowContext
>({ ... });