import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
import { IterableReadableStream } from "@langchain/core/utils/stream";
import { BaseChannel } from "../channels/base.js";
import { BaseCheckpointSaver, Checkpoint, ReadonlyCheckpoint } from "../checkpoint/base.js";
import { PregelNode } from "./read.js";
import { ChannelWrite } from "./write.js";
import { All, PregelExecutableTask, PregelTaskDescription, StateSnapshot } from "./types.js";
type WriteValue = Runnable | RunnableFunc<unknown, unknown> | unknown;
export declare class Channel {
    static subscribeTo(channels: string, options?: {
        key?: string;
        tags?: string[];
    }): PregelNode;
    static subscribeTo(channels: string[], options?: {
        tags?: string[];
    }): PregelNode;
    static writeTo(channels: string[], kwargs?: Record<string, WriteValue>): ChannelWrite;
}
export type StreamMode = "values" | "updates";
/**
 * Construct a type with a set of properties K of type T
 */
type StrRecord<K extends string, T> = {
    [P in K]: T;
};
export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>> {
    nodes: Nn;
    channels: Cc;
    inputs: keyof Cc | Array<keyof Cc>;
    outputs: keyof Cc | Array<keyof Cc>;
    /**
     * @default true
     */
    autoValidate?: boolean;
    /**
     * @default "values"
     */
    streamMode?: StreamMode;
    streamChannels?: keyof Cc | Array<keyof Cc>;
    /**
     * @default []
     */
    interruptAfter?: Array<keyof Nn> | All;
    /**
     * @default []
     */
    interruptBefore?: Array<keyof Nn> | All;
    /**
     * @default undefined
     */
    stepTimeout?: number;
    /**
     * @default false
     */
    debug?: boolean;
    checkpointer?: BaseCheckpointSaver;
}
export interface PregelOptions<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>> extends RunnableConfig {
    streamMode?: StreamMode;
    inputKeys?: keyof Cc | Array<keyof Cc>;
    outputKeys?: keyof Cc | Array<keyof Cc>;
    interruptBefore?: All | Array<keyof Nn>;
    interruptAfter?: All | Array<keyof Nn>;
    debug?: boolean;
}
export type PregelInputType = any;
export type PregelOutputType = any;
export declare class Pregel<const Nn extends StrRecord<string, PregelNode>, const Cc extends StrRecord<string, BaseChannel>> extends Runnable<PregelInputType, PregelOutputType, PregelOptions<Nn, Cc>> implements PregelInterface<Nn, Cc> {
    static lc_name(): string;
    lc_namespace: string[];
    nodes: Nn;
    channels: Cc;
    inputs: keyof Cc | Array<keyof Cc>;
    outputs: keyof Cc | Array<keyof Cc>;
    autoValidate: boolean;
    streamMode: StreamMode;
    streamChannels?: keyof Cc | Array<keyof Cc>;
    interruptAfter?: Array<keyof Nn> | All;
    interruptBefore?: Array<keyof Nn> | All;
    stepTimeout?: number;
    debug: boolean;
    checkpointer?: BaseCheckpointSaver;
    constructor(fields: PregelInterface<Nn, Cc>);
    validate(): this;
    get streamChannelsList(): Array<keyof Cc>;
    get streamChannelsAsIs(): keyof Cc | Array<keyof Cc>;
    getState(config: RunnableConfig): Promise<StateSnapshot>;
    getStateHistory(config: RunnableConfig, limit?: number, before?: RunnableConfig): AsyncIterableIterator<StateSnapshot>;
    updateState(config: RunnableConfig, values: Record<string, unknown> | unknown, asNode?: keyof Nn): Promise<RunnableConfig>;
    _defaults(config: PregelOptions<Nn, Cc>): [
        boolean,
        StreamMode,
        // stream mode
        keyof Cc | Array<keyof Cc>,
        // input keys
        keyof Cc | Array<keyof Cc>,
        RunnableConfig,
        // config without pregel keys
        All | Array<keyof Nn>,
        // interrupt before
        All | Array<keyof Nn>
    ];
    _transform(input: AsyncGenerator<PregelInputType>, runManager?: CallbackManagerForChainRun, config?: PregelOptions<Nn, Cc>): AsyncGenerator<PregelOutputType>;
    invoke(input: PregelInputType, options?: PregelOptions<Nn, Cc>): Promise<PregelOutputType>;
    stream(input: PregelInputType, config?: PregelOptions<Nn, Cc>): Promise<IterableReadableStream<PregelOutputType>>;
    transform(generator: AsyncGenerator<PregelInputType>, config?: PregelOptions<Nn, Cc>): AsyncGenerator<PregelOutputType>;
}
export declare function _shouldInterrupt<N extends PropertyKey, C extends PropertyKey>(checkpoint: ReadonlyCheckpoint, interruptNodes: All | Array<N>, snapshotChannels: Array<C>, tasks: Array<PregelExecutableTask<N, C>>): boolean;
export declare function _localRead<Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, channels: Cc, writes: Array<[keyof Cc, unknown]>, select: Array<keyof Cc> | keyof Cc, fresh?: boolean): Record<string, unknown> | unknown;
export declare function _applyWrites<Cc extends Record<string, BaseChannel>>(checkpoint: Checkpoint, channels: Cc, pendingWrites: Array<[keyof Cc, unknown]>): void;
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, forExecution: false): [Checkpoint, Array<PregelTaskDescription>];
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, forExecution: true): [Checkpoint, Array<PregelExecutableTask<keyof Nn, keyof Cc>>];
export {};
