remora-monorepo / lib / compileWorkflow
Function: compileWorkflow()
compileWorkflow(
workflow,options?):Promise<CompilerResult>
Defined in: packages/core/src/compiler/index.ts:39
Compiles a workflow definition through a multi-pass validation pipeline, producing an execution graph and structured diagnostics.
Passes: graph construction, reference validation, control flow validation, JMESPath validation, tool validation, for-each target validation, and best-practice transformations.
Parameters
workflow
The workflow definition to compile.
initialStepId
string = "string"
inputSchema?
object = ...
outputSchema?
object = ...
steps
({ description: string; id: string; name: string; nextStepId?: string; params: { toolInput: {[key: string]: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; toolName: string; }; type: "tool-call"; } | { description: string; id: string; name: string; nextStepId?: string; params: { outputFormat: object; prompt: string; }; type: "llm-prompt"; } | { description: string; id: string; name: string; nextStepId?: string; params: { outputFormat: object; sourceData: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "extract-data"; } | { description: string; id: string; name: string; nextStepId?: string; params: { cases: object[]; switchOn: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "switch-case"; } | { description: string; id: string; name: string; nextStepId?: string; params: { itemName: string; loopBodyStepId: string; target: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "for-each"; } | { description: string; id: string; name: string; nextStepId?: string; params: { durationMs: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "sleep"; } | { description: string; id: string; name: string; nextStepId?: string; params: { backoffMultiplier?: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; condition: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; conditionStepId: string; intervalMs?: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; maxAttempts?: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; timeoutMs?: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "wait-for-condition"; } | { description: string; id: string; name: string; nextStepId?: string; params: { instructions: string; maxSteps?: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; outputFormat: object; tools: string[]; }; type: "agent-loop"; } | { description: string; id: string; name: string; nextStepId?: string; type: "start"; } | { description: string; id: string; name: string; nextStepId?: string; params?: { output: { type: "literal"; value: unknown; } | { expression: string; type: "jmespath"; } | { template: string; type: "template"; }; }; type: "end"; })[] = ...
options?
Optional configuration.
limits?
tools?
ToolSet
Tool definitions to validate tool-call steps against. When provided, enables tool input validation and constrained schema generation.
Returns
Promise<CompilerResult>
A CompilerResult containing diagnostics, the execution graph (if structurally valid), an optimized workflow (if error-free), and constrained tool schemas (if tools were provided).