import type { Predicate } from '../predicate/index.js';
import type { ValidatableStepFlowEntry, WorkflowValidationInput } from '../stored/validate/types.js';
import type { SerializedSingleStepEntry, SerializedStepOptions } from '../types.js';
export type WorkflowBuilderJsonValue = string | number | boolean | null | WorkflowBuilderJsonValue[] | {
    [key: string]: WorkflowBuilderJsonValue;
};
export type WorkflowBuilderJsonObject = {
    [key: string]: WorkflowBuilderJsonValue;
};
export type WorkflowBuilderStepOptions = SerializedStepOptions;
/**
 * Authoring leaf entries are the canonical serialized leaf union minus
 * code-only `step` descriptors (a persisted definition cannot reference a
 * live Step object). Derived, not duplicated: when the serialized union
 * changes, these change with it.
 */
export type WorkflowBuilderSingleStepEntry = Exclude<SerializedSingleStepEntry, {
    type: 'step';
}>;
export type WorkflowBuilderAgentEntry = Extract<WorkflowBuilderSingleStepEntry, {
    type: 'agent';
}>;
export type WorkflowBuilderToolEntry = Extract<WorkflowBuilderSingleStepEntry, {
    type: 'tool';
}>;
export type WorkflowBuilderMappingEntry = Extract<WorkflowBuilderSingleStepEntry, {
    type: 'mapping';
}>;
export type WorkflowBuilderWorkflowEntry = Extract<WorkflowBuilderSingleStepEntry, {
    type: 'workflow';
}>;
export type WorkflowBuilderExecutableInnerEntry = Exclude<WorkflowBuilderSingleStepEntry, {
    type: 'mapping';
}>;
/**
 * Container entries are hand-written *narrowings* of the serialized union:
 * declarative predicates are required (closure conditions can't be authored),
 * fluent-only debug labels (`serializedConditions`/`serializedCondition`) are
 * absent, and `sleepUntil.date` is the wire's ISO string rather than a Date.
 * The static assertions at the bottom of this file prove each narrowing stays
 * inside the canonical union — drift is a compile error.
 */
export interface WorkflowBuilderParallelEntry {
    type: 'parallel';
    steps: WorkflowBuilderExecutableInnerEntry[];
}
export interface WorkflowBuilderForeachEntry {
    type: 'foreach';
    step: WorkflowBuilderExecutableInnerEntry;
    opts?: {
        concurrency: number;
    };
}
export interface WorkflowBuilderSleepEntry {
    type: 'sleep';
    id: string;
    duration: number;
}
export interface WorkflowBuilderSleepUntilEntry {
    type: 'sleepUntil';
    id: string;
    date: string;
}
export interface WorkflowBuilderConditionalEntry {
    type: 'conditional';
    steps: WorkflowBuilderExecutableInnerEntry[];
    predicates: Predicate[];
}
export interface WorkflowBuilderLoopEntry {
    type: 'loop';
    step: WorkflowBuilderExecutableInnerEntry;
    loopType: 'dowhile' | 'dountil';
    predicate: Predicate;
}
export type WorkflowBuilderGraphEntry = WorkflowBuilderSingleStepEntry | WorkflowBuilderParallelEntry | WorkflowBuilderForeachEntry | WorkflowBuilderSleepEntry | WorkflowBuilderSleepUntilEntry | WorkflowBuilderConditionalEntry | WorkflowBuilderLoopEntry;
export interface WorkflowBuilderDefinition {
    id: string;
    description?: string;
    metadata?: Record<string, unknown>;
    inputSchema: WorkflowBuilderJsonObject;
    outputSchema: WorkflowBuilderJsonObject;
    stateSchema?: WorkflowBuilderJsonObject;
    requestContextSchema?: WorkflowBuilderJsonObject;
    graph: WorkflowBuilderGraphEntry[];
}
type Extends<A, B> = [A] extends [B] ? true : false;
type Expect<T extends true> = T;
/**
 * Compile-time drift guards: the authoring universe must remain a subset of
 * the canonical serialized/wire union the validation core operates on. If a
 * serialized variant gains a required field (or an authoring type drifts),
 * these tuple members stop typechecking and the build fails.
 */
export type WorkflowBuilderTypeAssertions = [
    Expect<Extends<WorkflowBuilderGraphEntry, ValidatableStepFlowEntry>>,
    Expect<Extends<WorkflowBuilderDefinition, WorkflowValidationInput>>
];
export declare const WORKFLOW_BUILDER_SUPPORTED_STEP_TYPES: readonly ["agent", "tool", "mapping", "workflow", "parallel", "foreach", "sleep", "sleepUntil", "conditional", "loop"];
export type WorkflowBuilderSupportedStepType = (typeof WORKFLOW_BUILDER_SUPPORTED_STEP_TYPES)[number];
export declare function normalizeWorkflowBuilderDefinition(input: unknown): WorkflowBuilderDefinition;
export {};
//# sourceMappingURL=index.d.ts.map