import type { AgentRelayOptions } from '../relay.js';
import type { AgentCli, AgentPreset, CoordinationConfig, DryRunReport, IdleNudgeConfig, PathDefinition, RelayYamlConfig, StateConfig, SwarmPattern, TrajectoryConfig, VerificationCheck, WorkflowRunRow } from './types.js';
import { type WorkflowEventListener } from './runner.js';
import type { RunnerStepExecutor } from './types.js';
import { type LogLevel } from './default-logger.js';
import type { VariableContext } from './template-resolver.js';
export interface AgentOptions {
    cli: AgentCli;
    role?: string;
    task?: string;
    channels?: string[];
    model?: string;
    maxTokens?: number;
    timeoutMs?: number;
    retries?: number;
    /** Seconds of silence before considering the agent idle (for idle nudging). */
    idleThresholdSecs?: number;
    /** When false, the agent runs as a non-interactive subprocess (no PTY, no relay messaging).
     *  Default: true. */
    interactive?: boolean;
    /** Agent preset: 'lead' (interactive PTY), 'worker' | 'reviewer' | 'analyst' (non-interactive subprocess). */
    preset?: AgentPreset;
    /** Skills to make available to the agent (for API-mode agents). */
    skills?: string;
}
/** Options for agent steps (default). */
export interface AgentStepOptions {
    agent: string;
    task: string;
    cwd?: string;
    dependsOn?: string[];
    verification?: VerificationCheck;
    timeoutMs?: number;
    retries?: number;
}
/** Options for deterministic (shell command) steps. */
export interface DeterministicStepOptions {
    type: 'deterministic';
    command: string;
    cwd?: string;
    /** Capture stdout as step output for downstream steps. Default: true. */
    captureOutput?: boolean;
    /** Fail if command exit code is non-zero. Default: true. */
    failOnError?: boolean;
    dependsOn?: string[];
    verification?: VerificationCheck;
    timeoutMs?: number;
}
/** Options for worktree steps (create/checkout git worktrees). */
export interface WorktreeStepOptions {
    type: 'worktree';
    branch: string;
    baseBranch?: string;
    path?: string;
    createBranch?: boolean;
    dependsOn?: string[];
    timeoutMs?: number;
}
export type StepOptions = AgentStepOptions | DeterministicStepOptions | WorktreeStepOptions;
export interface ErrorOptions {
    maxRetries?: number;
    retryDelayMs?: number;
    notifyChannel?: string;
    repairAgent?: string;
    repairRetries?: number;
}
export type ReliabilityOptions = ErrorOptions;
export interface WorkflowRunOptions {
    /** Run a specific workflow by name (default: first). */
    workflow?: string;
    /** Template variable substitutions. */
    vars?: VariableContext;
    /** Working directory (default: process.cwd()). */
    cwd?: string;
    /** AgentRelay options (all optional). */
    relay?: AgentRelayOptions;
    /** Progress callback. */
    onEvent?: WorkflowEventListener;
    /** Validate and print execution plan without spawning agents. */
    dryRun?: boolean;
    /** External step executor (e.g. Daytona sandbox backend). */
    executor?: RunnerStepExecutor;
    /** Start from a specific step, skipping all predecessors. */
    startFrom?: string;
    /** Previous run ID whose cached outputs are used with startFrom. */
    previousRunId?: string;
    /** Console log verbosity: "verbose" | "normal" (default) | "quiet" | false (silent). */
    logLevel?: LogLevel;
    /** Renderer: "listr" for listr2 UI, "default" for console logger, false to disable. */
    renderer?: 'listr' | 'default' | false;
    /** Run the workflow in the cloud instead of locally. */
    cloud?: boolean;
    /** Cloud API base URL (or set CLOUD_API_URL env var). */
    cloudApiUrl?: string;
    /** Cloud API authentication token (or set CLOUD_API_TOKEN env var). */
    cloudApiToken?: string;
    /** Environment secrets to forward to cloud agents. */
    envSecrets?: Record<string, string>;
    /** Polling interval in ms for cloud run status checks. */
    cloudPollIntervalMs?: number;
    /** Callback invoked when the cloud run status changes. */
    onCloudStatusChange?: (status: string, runId: string) => void;
}
/**
 * Fluent builder for constructing workflow configurations programmatically.
 *
 * @example
 * ```typescript
 * import { workflow } from "@agent-relay/sdk/workflows";
 *
 * const result = await workflow("my-workflow")
 *   .pattern("dag")
 *   .agent("worker", { cli: "claude", role: "Backend engineer" })
 *   .step("build", { agent: "worker", task: "Build the project" })
 *   .step("test", { agent: "worker", task: "Run tests", dependsOn: ["build"] })
 *   .run();
 * ```
 */
export declare class WorkflowBuilder {
    private _name;
    private _description?;
    private _pattern;
    private _maxConcurrency?;
    private _timeoutMs?;
    private _channel?;
    private _idleNudge?;
    private _paths?;
    private _agents;
    private _steps;
    private _errorHandling?;
    private _coordination?;
    private _state?;
    private _trajectories?;
    private _startFrom?;
    private _previousRunId?;
    constructor(name: string);
    /** Set workflow description. */
    description(desc: string): this;
    /** Set swarm pattern (default: "dag"). */
    pattern(p: SwarmPattern): this;
    /** Set maximum concurrent agents. */
    maxConcurrency(n: number): this;
    /** Set global timeout in milliseconds. */
    timeout(ms: number): this;
    /** Set the relay channel for agent communication. */
    channel(ch: string): this;
    /** Configure idle agent detection and nudging for interactive agents. */
    idleNudge(config: IdleNudgeConfig): this;
    /** Set workflow coordination settings (barriers, voting threshold, consensus strategy). */
    coordination(config: CoordinationConfig): this;
    /** Configure shared workflow state backend settings. */
    state(config: StateConfig): this;
    /** Configure trajectory recording, or pass `false` to disable it. */
    trajectories(config: TrajectoryConfig | false): this;
    /** Start execution from a specific step, skipping all predecessor steps. */
    startFrom(stepName: string): this;
    /** Set the previous run ID whose cached step outputs should be used with startFrom. */
    previousRunId(id: string): this;
    /**
     * Declare named paths to additional directories the workflow needs.
     *
     * For multi-repo cloud workflows (relay#774, cloud#302), each entry is
     * tarballed by the CLI at submit time and mounted at
     * `/home/daytona/workspace/{name}/` in the sandbox. Locally, the runner
     * resolves `path` relative to the workflow file's parent directory and
     * agents reference each entry by its declared `name`.
     *
     * Calling this is a no-op for the runtime — the runner doesn't need
     * `paths` to execute steps. The CLI and the cloud bootstrap consume
     * it. Declaring via the builder keeps single-source-of-truth for tools
     * that walk the built config (e.g. dashboards, dry-run reports).
     */
    paths(paths: PathDefinition[]): this;
    /** Add an agent definition. */
    agent(name: string, options: AgentOptions): this;
    /** Add a workflow step (agent or deterministic). */
    step(name: string, options: StepOptions): this;
    /** Set error handling strategy. */
    onError(strategy: 'fail-fast' | 'continue' | 'retry', options?: ErrorOptions): this;
    /**
     * Opt into the product reliability contract: repairable workflow failures get
     * routed through an agent and retried before the workflow is allowed to fail.
     */
    repairable(options?: ReliabilityOptions): this;
    /** Alias for `.repairable()` for workflow authors who think in product terms. */
    reliable(options?: ReliabilityOptions): this;
    private validateBuilderState;
    /** Build and return the RelayYamlConfig object. */
    toConfig(): RelayYamlConfig;
    /** Serialize the config to a YAML string. */
    toYaml(): string;
    /** Build the config and execute it with the WorkflowRunner. */
    run(options: WorkflowRunOptions & {
        dryRun: true;
    }): Promise<DryRunReport>;
    run(options?: WorkflowRunOptions): Promise<WorkflowRunRow>;
}
/**
 * Create a new workflow builder.
 *
 * @example
 * ```typescript
 * const result = await workflow("my-task")
 *   .pattern("fan-out")
 *   .agent("worker", { cli: "claude" })
 *   .step("do-work", { agent: "worker", task: "Build the feature" })
 *   .run();
 * ```
 */
export declare function workflow(name: string): WorkflowBuilder;
//# sourceMappingURL=builder.d.ts.map