import { Workflow, type Client } from '@botpress/client';
import { z } from '@botpress/sdk';
import { BotClient } from '@botpress/sdk/dist/bot';
import { WorkflowDefinitions } from '../_types/workflows';
import { Autonomous } from '../runtime/autonomous';
import { TrackedState } from '../runtime/index';
export type WorkflowStepContext = {
    output?: unknown;
    attempts: number;
    startedAt: string;
    finishedAt?: string;
    steps?: Record<string, WorkflowStepContext>;
    error?: {
        message: string;
        failedAt: string;
        maxAttemptsReached: boolean;
    };
};
declare const StepSymbol: unique symbol;
type StepExecutionSignal = {
    [StepSymbol]: true;
};
export declare function isStepSignal(e: unknown): e is StepExecutionSignal;
export declare function createStepSignal(): StepExecutionSignal;
/**
 * Base class for all workflow instances
 */
export declare class BaseWorkflowInstance<TName extends keyof WorkflowDefinitions> {
    readonly id: string;
    readonly name: TName;
    readonly key?: string | undefined;
    readonly input: WorkflowDefinitions[TName]['input'];
    readonly createdAt: Date;
    readonly updatedAt: Date;
    readonly client: BotClient<any>;
    readonly workflow: Workflow;
    constructor(workflow: Workflow, client: BotClient<any>);
    get tags(): Record<string, string | undefined>;
    set tags(value: Record<string, string | undefined>);
    static readonly Primitive: "workflow_instance";
    static load<TName extends keyof WorkflowDefinitions>(props: {
        id: string;
        workflow?: Workflow;
    }): Promise<BaseWorkflowInstance<TName>>;
    /**
     * Executes the workflow with the provided autonomous engine configuration.
     * Workflows always run in "worker" mode (no chat capabilities).
     */
    execute(props: Autonomous.Props): Promise<import("llmz").ExecutionResult>;
    /**
     * Cancel the workflow execution.
     * Note: This should be called from within a proper bot handler context.
     * If calling from a conversation handler, ensure TrackedTags.loadAll() has been called.
     */
    cancel(): Promise<void>;
    /**
     * Provide data in response to a workflow data request (instance method).
     * Call this method from a conversation handler when you receive a WorkflowDataRequestEvent.
     * @param request - The name of the request being responded to
     * @param data - The data to provide to the workflow
     * @example
     * if (type === 'workflow_request') {
     *   await workflow.provide('topic', { topic: "Hello" });
     * }
     */
    provide<TRequest extends keyof WorkflowDefinitions[TName]['requests'] & string>(request: TRequest, data: WorkflowDefinitions[TName]['requests'][TRequest]): Promise<void>;
    /**
     * Returns a string representation for console.log
     */
    toString(): string;
    /**
     * Returns a JSON representation for serialization
     */
    toJSON(): any;
}
export declare function createWorkflowExecutionState(client: Client, workflowId: string): TrackedState<import("@botpress/sdk").ZodDefault<import("@botpress/sdk").ZodObject<{
    executionCount: import("@botpress/sdk").ZodDefault<import("@botpress/sdk").ZodNumber>;
    revision: import("@botpress/sdk").ZodDefault<import("@botpress/sdk").ZodNumber>;
    steps: import("@botpress/sdk").ZodRecord<import("@botpress/sdk").ZodString, z.ZodType<WorkflowStepContext>>;
}, "strip", {
    executionCount: number;
    revision: number;
    steps: Record<string, WorkflowStepContext>;
}, {
    steps: Record<string, WorkflowStepContext>;
    executionCount?: number | undefined;
    revision?: number | undefined;
}>>>;
export {};
//# sourceMappingURL=workflow-instance.d.ts.map