export type StateMachine = import("./state").StateMachine; export type Retry = import("./retry").Retry; export type Step = { /** * - Unique step identifier. */ id: string; /** * - Description of the step to execute. */ action: string; /** * - Ids of steps that must complete first. */ dependsOn?: string[] | undefined; }; export type TrackingEntry = { /** * - The (cloned) step being tracked. */ step: Step; /** * - Lifecycle status: pending/running/done/failed. */ status: string; /** * - Result returned by executeFn on success. */ result: any; /** * - Error message on failure. */ error: string | undefined; }; export type RunPlanOptions = { /** * - Max parallel steps per wave. */ concurrency?: number | undefined; /** * - StateMachine instance for lifecycle tracking. */ stateMachine?: import("./state").StateMachine | undefined; /** * - Callback fired when a step begins. */ onStepStart?: ((step: Step) => void) | undefined; /** * - Callback fired on success. */ onStepDone?: ((step: Step, result: any) => void) | undefined; /** * - Callback fired on failure. */ onStepFail?: ((step: Step, error: Error) => void) | undefined; /** * - Callback fired before each wave executes. */ onWaveStart?: ((waveNumber: number, steps: Step[]) => void) | undefined; /** * - Optional Retry instance wrapping each step execution. */ stepRetry?: import("./retry").Retry | undefined; }; export type StepResult = { /** * - Step id. */ id: string; /** * - Final status. */ status: string; /** * - Result value if the step succeeded. */ result?: any; /** * - Error message if the step failed. */ error?: string | undefined; }; /** @typedef {import('./state').StateMachine} StateMachine */ /** @typedef {import('./retry').Retry} Retry */ /** * @typedef {object} Step * @property {string} id - Unique step identifier. * @property {string} action - Description of the step to execute. * @property {string[]} [dependsOn] - Ids of steps that must complete first. */ /** * @typedef {object} TrackingEntry * @property {Step} step - The (cloned) step being tracked. * @property {string} status - Lifecycle status: pending/running/done/failed. * @property {*} result - Result returned by executeFn on success. * @property {string|undefined} error - Error message on failure. */ /** * @typedef {object} RunPlanOptions * @property {number} [concurrency=Infinity] - Max parallel steps per wave. * @property {StateMachine} [stateMachine] - StateMachine instance for lifecycle tracking. * @property {(step: Step) => void} [onStepStart] - Callback fired when a step begins. * @property {(step: Step, result: any) => void} [onStepDone] - Callback fired on success. * @property {(step: Step, error: Error) => void} [onStepFail] - Callback fired on failure. * @property {(waveNumber: number, steps: Step[]) => void} [onWaveStart] - Callback fired before each wave executes. * @property {Retry} [stepRetry] - Optional Retry instance wrapping each step execution. */ /** * @typedef {object} StepResult * @property {string} id - Step id. * @property {string} status - Final status. * @property {*} [result] - Result value if the step succeeded. * @property {string} [error] - Error message if the step failed. */ /** * Execute a step DAG with wave-based parallelism. * @param {Step[]} steps - Steps from Planner. * @param {(step: Step) => any} executeFn - Async function called for each step: (step) => result. * @param {RunPlanOptions} [options={}] * @returns {Promise} * @throws {Error} `[runPlan] steps must be a non-empty array` — when steps is not a non-empty array. * @throws {Error} `[runPlan] executeFn must be a function` — when executeFn is not a function. * @throws {Error} `[runPlan] duplicate step id: "X"` — when two steps share an id. * @throws {Error} `[runPlan] step "X" depends on unknown step "Y"` — when dependsOn references missing id. * @when you have a step DAG from the Planner and want to execute it with wave-based parallelism (independent steps run concurrently) * @fails throws on a malformed DAG (empty steps, non-function executeFn, duplicate ids, unknown dependency); a step's own error surfaces per StepResult, never crashing the wave. * @example * const steps = await planner.plan(goal); * const results = await runPlan(steps, step => execute(step)); */ export function runPlan(steps: Step[], executeFn: (step: Step) => any, options?: RunPlanOptions): Promise;