/**
 * WorkflowEngine — execute, checkpoint, resume, and abort workflow runs.
 *
 * Story 4.2 — OpenLife v1.2 Royal Stack.
 *
 * The engine is the maestro. It iterates the workflow `sequence`,
 * dispatches each executable step through an injected
 * `WorkflowStepExecutor` (default = Gatekeeper-backed), records
 * progress to `.openlife/workflows/<runId>.json` via AtomicWriter,
 * appends a step-level event log to `.openlife/workflows/events/
 * <runId>.jsonl`, and saves a MissionCheckpoint after each successful
 * step.
 *
 * Crash safety: every state transition is durable. If the daemon dies
 * mid-step, calling `resume(runId)` reads the last checkpoint and
 * continues from the next pending step (idempotent steps may re-execute
 * once; non-idempotent are skipped to avoid double-side-effects).
 *
 * Elicit support: a step with `elicit: true` causes the engine to set
 * run status to `awaiting_input` and return control. The caller must
 * later invoke `provideInput(runId, stepId, payload)` to resume.
 */
import { Workflow, WorkflowExecutableStep } from './WorkflowSchema';
import { WorkflowRunState } from './WorkflowState';
import { MissionCheckpointStore } from '../MissionState';
export interface WorkflowStepInvocation {
    runId: string;
    step: WorkflowExecutableStep;
    context: Record<string, unknown>;
}
export interface WorkflowStepResult {
    status: 'completed' | 'skipped' | 'failed' | 'awaiting_input';
    artifacts?: string[];
    /** Stringified result payload (typically JSON.stringify of an envelope). */
    result?: string;
    error?: string;
}
export interface WorkflowStepExecutor {
    execute(invocation: WorkflowStepInvocation): Promise<WorkflowStepResult>;
}
export declare class SimulatedStepExecutor implements WorkflowStepExecutor {
    execute(inv: WorkflowStepInvocation): Promise<WorkflowStepResult>;
}
export interface WorkflowEngineOptions {
    /** Override state directory (defaults to OPENLIFE_STATE_DIR or .openlife/). */
    stateDir?: string;
    /** Step executor; defaults to SimulatedStepExecutor. */
    executor?: WorkflowStepExecutor;
    /** Checkpoint store; defaults to a new MissionCheckpointStore. */
    checkpointStore?: MissionCheckpointStore;
}
export declare class WorkflowEngine {
    private readonly stateDir;
    private readonly executor;
    private readonly checkpointStore;
    constructor(opts?: WorkflowEngineOptions);
    /** Pick the default step executor. Simulated unless OPENLIFE_REAL_WORKFLOW=1,
     *  in which case steps run through real catalog/method agents (Phase 5).
     *  Heavy deps are lazy-required only when the real executor is requested, so
     *  deterministic commands and dry-runs stay fast and free. */
    private static defaultExecutor;
    /**
     * Execute a workflow from scratch. Returns the final WorkflowRunState
     * (the caller is responsible for inspecting `status` — terminal states
     * are `completed`, `failed`, `aborted`, or `awaiting_input`).
     */
    run(workflow: Workflow, context?: Record<string, unknown>, opts?: {
        allowServiceMode?: boolean;
    }): Promise<WorkflowRunState>;
    /**
     * Read the persisted state for a run without modifying it.
     */
    status(runId: string): WorkflowRunState | null;
    /**
     * Resume a previously-paused or crashed run. Requires the original
     * Workflow (the engine does not persist workflow definitions — only
     * runs of them, identified by `workflowId` in state).
     */
    resume(workflow: Workflow, runId: string): Promise<WorkflowRunState>;
    /**
     * Mark a run as aborted. Idempotent.
     */
    abort(runId: string, reason?: string): WorkflowRunState | null;
    /**
     * Provide user input for a step that paused with elicit. Re-runs that
     * step with the input merged into context.
     */
    provideInput(workflow: Workflow, runId: string, stepId: string, payload: Record<string, unknown>): Promise<WorkflowRunState>;
    private executeFrom;
    private conditionMet;
    private findResumeIndex;
    private persistState;
    private emitEvent;
    private stateFilePath;
    private eventLogPath;
    private newRunId;
    /** Exposed for tests so they can assert resolved storage location. */
    _stateDir(): string;
}
