import type { ChannelSchema, GraphEvent, GraphResult, GraphStepEvent, GraphStreamEvent, GraphStreamOverflow, GraphStreamProjection, GraphStreamStats } from '../types/graph.js'; import { GraphError } from './errors.js'; /** Raised by an event stream whose reader fell behind with `overflow: 'error'`. The run is stopped. */ export declare class GraphStreamOverflowError extends GraphError { /** The buffer that filled. */ readonly maxBuffered: number; constructor( /** The buffer that filled. */ maxBuffered: number); } /** What starts the run behind a stream: given the event listener and a signal, the step events. */ export type GraphRunStarter = (onEvent: (event: GraphEvent) => void, signal: AbortSignal) => AsyncIterable>; interface StreamSettings { include: GraphStreamProjection[]; subgraphs: boolean; maxBuffered: number; overflow: GraphStreamOverflow; } /** * A graph run as one stream of typed events, with each projection readable on its own. * * Iterate the stream for every included event, or take `messages()`, `tools()`, `values()`, or * `updates()` for one kind. Every reader gets its own bounded buffer. The run starts when the first * reader asks for an event, so create every reader before reading any. It stops when every reader * has stopped. */ export declare class GraphEventStream implements AsyncIterable> { private readonly start; private readonly toResult; private readonly settings; private readonly readers; private readonly controller; private started; private readonly stats; private resolveResult; private rejectResult; /** Resolves with the run's result once it ends, or rejects with its error. */ readonly result: Promise>; constructor(start: GraphRunStarter, toResult: (last: GraphStepEvent | undefined) => GraphResult, settings: StreamSettings); /** Every included event. */ [Symbol.asyncIterator](): AsyncIterator>; /** Model output, as nodes stream it. */ messages(): AsyncIterable, { type: 'messages'; }>>; /** Tool calls: each starting, progressing, and returning or failing. */ tools(): AsyncIterable, { type: 'tools'; }>>; /** The state after each superstep. */ values(): AsyncIterable, { type: 'values'; }>>; /** Each task's write. */ updates(): AsyncIterable, { type: 'updates'; }>>; /** How the stream kept up with its slowest reader so far. */ streamStats(): GraphStreamStats; /** A reader for one projection, registered now so it sees the run from its first event. */ private only; private reader; private begin; private publish; private fail; private pump; } /** Builds a stream's settings from its options. */ export declare function streamSettings(options: { include?: GraphStreamProjection[]; subgraphs?: boolean; maxBuffered?: number; overflow?: GraphStreamOverflow; }): StreamSettings; export {};