import { BaseCheckpointSaver, Checkpoint, ReadonlyCheckpoint } from "@langchain/langgraph-checkpoint";
import { RunnableConfig } from "@langchain/core/runnables";

//#region src/channels/base.d.ts
/**
 * Structural check for a {@link DeltaChannel} without importing it (avoids an
 * import cycle: `delta.ts` imports `base.ts`).
 */
declare function isDeltaChannel(channel: BaseChannel): boolean;
/** @internal */
declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {
  ValueType: ValueType;
  UpdateType: UpdateType;
  /**
   * The name of the channel.
   */
  abstract lc_graph_name: string;
  /** @ignore */
  lg_is_channel: boolean;
  /**
   * Return a new identical channel, optionally initialized from a checkpoint.
   * Can be thought of as a "restoration" from a checkpoint which is a "snapshot" of the channel's state.
   *
   * @param {CheckpointType | undefined} checkpoint
   * @param {CheckpointType | undefined} initialValue
   * @returns {this}
   */
  abstract fromCheckpoint(checkpoint?: CheckpointType): this;
  /**
   * Update the channel's value with the given sequence of updates.
   * The order of the updates in the sequence is arbitrary.
   * This method is called by Pregel for all channels at the end of each step.
   * If there are no updates, it is called with an empty sequence.
   *
   * Raises InvalidUpdateError if the sequence of updates is invalid.
   * Returns True if the channel was updated, False otherwise.
   *
   * @throws {InvalidUpdateError} if the sequence of updates is invalid.
   * @param {Array<UpdateType>} values
   * @returns {void}
   */
  abstract update(values: UpdateType[]): boolean;
  /**
   * Return the current value of the channel.
   *
   * @throws {EmptyChannelError} if the channel is empty (never updated yet).
   * @returns {ValueType}
   */
  abstract get(): ValueType;
  /**
   * Return a string representation of the channel's current state.
   *
   * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.
   * @returns {CheckpointType | undefined}
   */
  abstract checkpoint(): CheckpointType | undefined;
  /**
   * Mark the current value of the channel as consumed. By default, no-op.
   * A channel can use this method to modify its state, preventing the value
   * from being consumed again.
   *
   * Returns True if the channel was updated, False otherwise.
   */
  consume(): boolean;
  /**
   * Notify the channel that the Pregel run is finishing. By default, no-op.
   * A channel can use this method to modify its state, preventing finish.
   *
   * Returns True if the channel was updated, False otherwise.
   */
  finish(): boolean;
  /**
   * Return True if the channel is available (not empty), False otherwise.
   * Subclasses should override this method to provide a more efficient
   * implementation than calling get() and catching EmptyChannelError.
   */
  isAvailable(): boolean;
  /**
   * Compare this channel with another channel for equality.
   * Used to determine if two channels with the same key are semantically equivalent.
   * Subclasses should override this method to provide a meaningful comparison.
   *
   * @param {BaseChannel} other - The other channel to compare with.
   * @returns {boolean} True if the channels are equal, false otherwise.
   */
  equals(other: BaseChannel): boolean;
}
declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;
/**
 * Synthetic task id for exit-mode DeltaChannel writes.
 *
 * Embeds the superstep in the first UUID group so `ORDER BY task_id, idx`
 * preserves chronological order while remaining a valid RFC UUID (required by
 * Postgres `checkpoint_writes.task_id uuid` columns).
 */
declare function exitDeltaTaskId(step: number, taskId: string): string;
/**
 * Return the set of {@link DeltaChannel} names that should snapshot now.
 *
 * A channel snapshots when EITHER its accumulated update count reaches
 * `snapshotFrequency` OR the total supersteps since its last snapshot reaches
 * `DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`. Pure predicate — no mutation.
 */
declare function deltaChannelsToSnapshot(channels: Record<string, BaseChannel>, countersSinceDeltaSnapshot: Record<string, [number, number]>): Set<string>;
declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {
  id?: string;
  channelsToSnapshot?: Set<string>;
  updatedChannels?: Set<string>;
  getNextVersion?: (current: number | string | undefined) => number | string;
}): Checkpoint;
/**
 * Hydrate channels from a checkpoint, reconstructing any {@link DeltaChannel}
 * whose value is absent from `channel_values` by replaying ancestor writes.
 *
 * For most channels (and for delta channels with a {@link DeltaSnapshot} or a
 * migrated plain value in `channel_values`), {@link emptyChannels} is
 * sufficient and no saver access is required. When a delta channel is absent
 * from `channel_values`, an ancestor walk via `saver.getDeltaChannelHistory`
 * finds the nearest seed and accumulates the writes between it and the
 * target. All delta channels needing replay are batched into a single saver
 * call.
 */
declare function channelsFromCheckpoint<Cc extends Record<string, BaseChannel>>(specs: Cc, checkpoint: ReadonlyCheckpoint, options?: {
  saver?: BaseCheckpointSaver;
  config?: RunnableConfig;
}): Promise<Cc>;
//#endregion
export { BaseChannel, channelsFromCheckpoint, createCheckpoint, deltaChannelsToSnapshot, emptyChannels, exitDeltaTaskId, isDeltaChannel };
//# sourceMappingURL=base.d.cts.map