import type { Observable } from 'rxjs';
import type { PartialDeep } from 'type-fest';
import type { LlmCall } from '../types/LlmCall';
import type { number_percent } from '../types/number_percent';
import type { task_id } from '../types/string_token';
import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
import type { chococake } from '../utils/organization/really_any';
import type { string_promptbook_version } from '../version';
import type { AbstractTaskResult } from './AbstractTaskResult';
import type { PipelineExecutorResult } from './PipelineExecutorResult';
/**
 * Options for creating a new task
 */
type CreateTaskOptions<TTaskResult extends AbstractTaskResult> = {
    /**
     * The type of task to create
     */
    readonly taskType: AbstractTask<TTaskResult>['taskType'];
    /**
     * Human-readable title of the task - used for displaying in the UI
     */
    readonly title: AbstractTask<TTaskResult>['title'];
    /**
     * Callback that processes the task and updates the ongoing result
     * @param updateOngoingResult Function to update the partial result of the task processing
     * @param updateTldr Function to update tldr progress information
     * @returns The final task result
     */
    taskProcessCallback(updateOngoingResult: (newOngoingResult: PartialDeep<TTaskResult> & {
        /**
         * Optional update of the task title
         */
        readonly title?: AbstractTask<TTaskResult>['title'];
    }) => void, updateTldr: (tldrInfo: {
        readonly percent: number_percent;
        readonly message: string;
    }) => void, logLlmCall: (llmCall: LlmCall) => void): Promise<TTaskResult>;
};
/**
 * Helper to create a new task
 *
 * @private internal helper function
 */
export declare function createTask<TTaskResult extends AbstractTaskResult>(options: CreateTaskOptions<TTaskResult>): AbstractTask<TTaskResult>;
/**
 * Represents a task that executes a pipeline
 */
export type ExecutionTask = AbstractTask<PipelineExecutorResult> & {
    readonly taskType: 'EXECUTION';
    readonly taskId: `exec-${task_id}`;
};
/**
 * Represents a task that prepares a pipeline
 *
 * @deprecated TODO: [🐚] Currently unused - use
 */
export type PreparationTask = AbstractTask<PipelineExecutorResult> & {
    readonly taskType: 'PREPARATION';
    readonly taskId: `prep-${task_id}`;
};
/**
 * Status of a task
 */
export type task_status = 'RUNNING' | 'FINISHED' | 'ERROR';
/**
 * Base interface for all task types
 */
export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
    /**
     * Type of the task
     */
    readonly taskType: string_SCREAMING_CASE;
    /**
     * Version of the promptbook used to run the task
     */
    readonly promptbookVersion: string_promptbook_version;
    /**
     * Unique identifier for the task
     */
    readonly taskId: task_id;
    /**
     * Human-readable title of the task - used for displaying in the UI
     *
     * For example name of the book which is being executed
     */
    readonly title: string;
    /**
     * Status of the task
     */
    readonly status: task_status;
    /**
     * Short summary of the task status for quick overview in the UI
     */
    readonly tldr: {
        /**
         * Progress in percentage from 0 to 1 (100%) that can be used to display a progress bar
         */
        readonly percent: number_percent;
        /**
         * Short summary message of the task status that can be displayed in the UI
         */
        readonly message: string;
    };
    /**
     * Date when the task was created
     */
    readonly createdAt: Date;
    /**
     * Date when the task was last updated
     */
    readonly updatedAt: Date;
    /**
     * Gets a promise that resolves with the task result
     */
    asPromise(options?: {
        /**
         * Do the task throws on error
         *
         * - If `true` when error occurs the returned promise will rejects
         * - If `false` the promise will resolve with object with all listed errors and warnings and partial result
         *
         * @default true
         */
        readonly isCrashedOnError?: boolean;
    }): Promise<TTaskResult>;
    /**
     * Gets an observable stream of partial task results
     */
    asObservable(): Observable<PartialDeep<TTaskResult>>;
    /**
     * Gets just the current value which is mutated during the task processing
     */
    readonly currentValue: PartialDeep<TTaskResult>;
    /**
     * List of errors that occurred during the task processing
     */
    readonly errors: Array<Error>;
    /**
     * List of warnings that occurred during the task processing
     */
    readonly warnings: Array<Error>;
    /**
     * List of LLM calls that occurred during the task processing
     */
    readonly llmCalls: Array<LlmCall>;
    /**
     * Optional nonce to correlate logs with version of the Promptbook engine
     */
    readonly ptbkNonce?: chococake;
};
/**
 * Type describing task.
 */
export type Task = ExecutionTask | PreparationTask;
export {};
