import { StreamEvent } from "../contracts/stream/stream-event.type.mjs"; import { StreamContract } from "../contracts/stream/stream.contract.mjs"; //#region ../ai/src/agent/agent-stream.d.ts /** * Internal async-queue `StreamContract` used by `agent().stream()`. * * **Role.** The bridge between a streaming `Execution` (which runs in the * background, pushing events as they happen) and a consumer that reads * those events with `for await` or an `on(...)` handler map. * * **Responsibility.** * - Owns: the event queue, the pending-read promise chain, the terminal * `result` promise, and any user-registered event handlers. * - Does NOT own: any knowledge of agents, models, or tool calls — it is a * generic producer/consumer pipe parameterized by `TResult`. The streaming * execution writes via `push()` / `end()` / `fail()`; the consumer reads * via the AsyncIterable surface. * * Events are coalesced into a queue so that a consumer that starts * iterating late still sees every event in order — nothing is dropped. The * `on()` handlers fire the moment an event is pushed, independent of * whether anyone is iterating. * * @example * // Inside agent.stream(): * const { controller, stream } = createAgentStream>(); * new Execution(config, input, options, controller).run(); * return stream; * * // Consumer: * for await (const event of stream) { * if (event.type === "streaming") process.stdout.write(event.delta); * } * const result = await stream.result; */ type StreamController = { push(event: StreamEvent): void; end(result: TResult): void; fail(error: Error): void; }; declare function createAgentStream(): { controller: StreamController; stream: StreamContract; }; //#endregion export { StreamController, createAgentStream }; //# sourceMappingURL=agent-stream.d.mts.map