import { z, ZodType } from '@botpress/sdk';
import { ZuiType } from '../types';
import { WorkflowDefinitions } from '../_types/workflows';
import { BaseWorkflowInstance } from './workflow-instance';
import type { WorkflowStep } from './workflow-step';
import type { BaseBot, BotClient } from '@botpress/sdk/dist/bot';
import { Workflow } from '@botpress/client';
import { Autonomous } from '../runtime/autonomous';
import { WorkflowDataRequestEvent } from '../runtime';
export declare namespace Typings {
    type StepCallSignature = <T>(name: string, run: ({ attempt }: {
        attempt: number;
    }) => T | Promise<T>, options?: {
        maxAttempts?: number;
    }) => Promise<T>;
    type StepMethods = Pick<WorkflowStep, 'listen' | 'fail' | 'progress' | 'abort' | 'sleep' | 'sleepUntil' | 'waitForWorkflow' | 'executeWorkflow' | 'map' | 'forEach' | 'batch'>;
    export type TypedWorkflowStep<Requests extends Record<string, ZuiType>> = StepCallSignature & StepMethods & {
        /**
         * Request data from the conversation and wait for a response.
         * The workflow will pause and send a data request event to the conversation.
         * Use WorkflowInstance.provide() in the conversation handler to respond.
         * @param request - The name of the request (must be defined in workflow requests)
         * @param message - Message to display to the user describing what data is needed
         * @param stepName - Optional custom name for the step (defaults to request)
         * @returns The provided data validated against the request schema
         * @throws Error if workflow has no conversationId or request not found
         */
        request<TRequest extends keyof Requests & string>(request: TRequest, message: string, stepName?: string): Promise<z.infer<Requests[TRequest]>>;
    };
    export type HandlerProps<Input extends ZuiType = ZuiType, _Output extends ZuiType = ZuiType, State extends ZuiType = ZuiType, Requests extends Record<string, ZuiType> = Record<string, ZuiType>, TBot extends BaseBot = BaseBot> = {
        input: z.infer<Input>;
        state: z.infer<State>;
        step: TypedWorkflowStep<Requests>;
        client: BotClient<TBot>;
        execute: Autonomous.ExecuteFn;
    };
    export type Handler<TName extends string = string, Input extends ZuiType = ZuiType, Output extends ZuiType = ZuiType, State extends ZuiType = ZuiType, Requests extends Record<string, ZuiType> = Record<string, ZuiType>> = (props: HandlerProps<Input, Output, State, Requests>) => Promise<z.infer<Output>> | z.infer<Output>;
    export type Props<TName extends string = string, Input extends ZuiType = ZuiType, Output extends ZuiType = ZuiType, State extends ZuiType = ZuiType, Requests extends Record<string, ZuiType> = Record<string, ZuiType>> = {
        name: TName;
        description?: string;
        input?: Input;
        output?: Output;
        state?: State;
        requests?: Requests;
        handler: Handler<TName, Input, Output, State, Requests>;
        schedule?: string;
        timeout?: `${number}s` | `${number}m` | `${number}h`;
    };
    export const Primitive: "workflow";
    export {};
}
export declare class BaseWorkflow<TName extends string = string, Input extends ZuiType = WorkflowDefinitions[TName] extends never ? ZuiType : WorkflowDefinitions[TName]['input'] extends ZodType ? WorkflowDefinitions[TName]['input'] : ZuiType, Output extends ZuiType = WorkflowDefinitions[TName] extends never ? ZuiType : WorkflowDefinitions[TName]['output'] extends ZodType ? WorkflowDefinitions[TName]['output'] : ZuiType, State extends ZuiType = WorkflowDefinitions[TName] extends never ? ZuiType : WorkflowDefinitions[TName]['state'] extends ZodType ? WorkflowDefinitions[TName]['state'] : ZuiType, Requests extends Record<string, ZuiType> = Record<string, ZuiType>> {
    readonly name: TName;
    readonly description?: string;
    readonly timeout: number;
    constructor(props: Typings.Props<TName, Input, Output, State, Requests>);
    /**
     * Get or create a workflow instance with the given key and input
     *
     * @param props.key - Optional unique key for workflow deduplication
     * @param props.start - Whether to start the workflow immediately (default: true)
     * @param props.input - The input data for the workflow
     * @returns The workflow instance
     */
    getOrCreate(props: {
        key?: string;
        statuses?: Workflow['status'][];
        input: WorkflowDefinitions[TName] extends never ? z.infer<Input> : WorkflowDefinitions[TName]['input'];
    }): Promise<BaseWorkflowInstance<TName>>;
    /**
     * Provide data in response to a workflow data request.
     * Call this method from a conversation handler when you receive a WorkflowDataRequestEvent.
     * @param event - The event object from the conversation handler
     * @param data - The data to provide to the workflow
     * @example
     * if (isWorkflowDataRequest(event)) {
     *   await SomeWorkflow.provide(event, { orderId: "12345" });
     * }
     */
    provide(event: {
        type: string;
        payload: z.infer<typeof WorkflowDataRequestEvent.schema>;
    }, data: any): Promise<void>;
    start(input: z.infer<Input>): Promise<BaseWorkflowInstance<TName>>;
}
//# sourceMappingURL=workflow.d.ts.map