import type { SlopeStore } from './store.js'; import type { WorkflowExecution } from './types.js'; import type { WorkflowDefinition, WorkflowStep } from './workflow.js'; /** Options for starting a workflow execution */ export interface StartOpts { sprint_id?: string; variables?: Record; session_id?: string; } /** Information about the next step to execute */ export interface NextStepInfo { /** Whether the entire workflow is complete */ is_complete: boolean; /** Phase ID of the next step (undefined if complete) */ phase?: string; /** The step to execute (undefined if complete) */ step?: WorkflowStep; /** For repeat_for phases: the current item being iterated */ current_item?: string; /** Total items in repeat_for phase (if applicable) */ total_items?: number; /** Index of current item (0-based, if applicable) */ item_index?: number; } /** Result of advancing after completing/skipping a step */ export interface AdvanceResult { /** The phase/step that was advanced to (or undefined if workflow complete) */ advanced_to?: { phase: string; step: string; }; /** Whether the entire workflow is now complete */ is_complete: boolean; /** Hint for what to do next */ next_action?: string; } /** Result of completing a step */ export interface StepResult { output?: Record; exit_code?: number; /** When the step actually started (for accurate duration tracking) */ started_at?: string; } export declare class WorkflowEngine { /** * Start a new workflow execution. * Creates a store record and positions at the first step of the first phase. */ start(def: WorkflowDefinition, store: SlopeStore, opts?: StartOpts): Promise; /** * Determine what should happen next for an execution. * Returns the current step to execute, or is_complete if done. */ next(executionId: string, def: WorkflowDefinition, store: SlopeStore): Promise; /** * Complete a step and advance the execution. * Records the step result and moves to the next step/phase. */ complete(executionId: string, stepId: string, result: StepResult, def: WorkflowDefinition, store: SlopeStore): Promise; /** * Skip a step and advance. Skipped steps count as "done" for phase advancement. */ skip(executionId: string, stepId: string, reason: string, def: WorkflowDefinition, store: SlopeStore): Promise; /** * Transition execution to failed status. */ fail(executionId: string, store: SlopeStore): Promise; /** * Pause a running execution. Preserves current phase/step for later resume. */ pause(executionId: string, store: SlopeStore): Promise; /** * Resume a paused execution. Continues from the same phase/step. */ resume(executionId: string, store: SlopeStore): Promise; private requireExecution; private validateCurrentStep; /** * Find the next incomplete step in the workflow. * Handles repeat_for phases by expanding the iteration. */ private findNextStep; /** * After completing/skipping a step, advance to the next step or complete the workflow. */ private advanceToNext; /** * Get the items to iterate over for a repeat_for phase. * Looks up the variable name and splits comma-separated values or parses JSON array. */ private getRepeatItems; /** Human-readable description of what a step expects */ private describeStep; } //# sourceMappingURL=workflow-engine.d.ts.map