import type { RunnableCommandName } from "./commandRunner"; import { AppError } from "./errors"; import type { CommandContext } from "./types"; export type RunbookPrimitive = string | number | boolean; export type RunbookVariables = Record; export interface RunbookStepDefinition { command: string; args?: Array; flags?: Record; label?: string; continueOnError?: boolean; retry?: number; retryBackoffMs?: number; minDelayMs?: number; maxDelayMs?: number; } export interface RunbookDefinition { description?: string; variables?: RunbookVariables; continueOnError?: boolean; steps: RunbookStepDefinition[]; } export interface BatchTargetDefinition { name?: string; sessionId?: string; profileId?: string; variables?: RunbookVariables; continueOnError?: boolean; } export interface BatchDefinition { concurrency?: number; variables?: RunbookVariables; targets: BatchTargetDefinition[]; } export interface RunbookExecutionOptions { sessionId?: string; profileId?: string; variables?: RunbookVariables; continueOnError?: boolean; cycle?: number; } export interface RunbookStepResult { command: string; label?: string; cycle?: number; status: "ok" | "failed"; durationMs: number; attempts: number; error?: string; } export interface RunbookExecutionResult { steps: RunbookStepResult[]; aborted?: boolean; abortReason?: string; } export interface BatchTargetResult { name: string; sessionId: string; profileId?: string; status: "ok" | "failed"; durationMs: number; output: string; error?: string; steps: RunbookStepResult[]; } export declare class RunbookExecutionError extends AppError { readonly steps: RunbookStepResult[]; readonly cause: unknown; constructor(error: unknown, steps: RunbookStepResult[]); } export declare function loadRunbookDefinition(baseDir: string, filePath: string): RunbookDefinition; export declare function loadBatchDefinition(baseDir: string, filePath: string): BatchDefinition; export declare function buildStepInvocation(step: RunbookStepDefinition, variables: RunbookVariables, options?: Pick): { command: RunnableCommandName; argv: string[]; }; export declare function executeRunbook(context: CommandContext, runbook: RunbookDefinition, options?: RunbookExecutionOptions): Promise; export declare function executeBatch(context: CommandContext, runbook: RunbookDefinition, batch: BatchDefinition, options?: { concurrency?: number; variables?: RunbookVariables; continueOnError?: boolean; }): Promise; export declare function prefixMultiline(text: string, prefix: string): string; export declare function loadVariablesFile(baseDir: string, filePath: string): RunbookVariables;