import type { AgentAttachEvent, LogRecord, SubscriptionCloseReason, WatchEvent, WatchParams, WatchResult } from './generated/protocol.js'; import { Connection } from './connection.js'; import type { SubscriptionRegistration } from './connection.js'; import type { FrameRecord } from './frames.js'; export type SubscriptionClosedItem = { readonly type: 'closed'; readonly reason: SubscriptionCloseReason; }; export type WatchSubscriptionClosedItem = SubscriptionClosedItem & { readonly lastDeliveredCursor?: string | null; }; export type SubscriptionItem = { readonly type: 'event'; readonly event: T; } | SubscriptionClosedItem; export type WatchSubscriptionItem = { readonly type: 'event'; readonly runId: string; readonly cursor: string; readonly event: WatchEvent; } | WatchSubscriptionClosedItem; export interface Subscription extends AsyncIterator>, AsyncIterable> { readonly subscriptionId: string; readonly retainedCount: number; cancel(): Promise; } export interface WatchSubscription { readonly result: WatchResult; readonly stream: WatchSubscriptionStream; } type FrameParser = (frame: FrameRecord) => SubscriptionItem; declare class SubscriptionStream implements Subscription { #private; protected readonly connection: Connection; protected readonly registration: SubscriptionRegistration; private readonly parse; constructor(connection: Connection, registration: SubscriptionRegistration, parse: FrameParser); get subscriptionId(): string; get retainedCount(): number; [Symbol.asyncIterator](): this; next(): Promise>>; return(): Promise>>; throw(error?: unknown): Promise>>; cancel(): Promise; } export declare class LogsSubscriptionStream extends SubscriptionStream { constructor(connection: Connection, registration: SubscriptionRegistration); } export declare class AgentAttachSubscriptionStream extends SubscriptionStream { constructor(connection: Connection, registration: SubscriptionRegistration); } type WatchStreamInit = { readonly connection: Connection; readonly registration: SubscriptionRegistration; readonly result: WatchResult; readonly params: WatchParams; readonly lastSeenRunId?: string; readonly lastSeenCursor?: string; }; export declare class WatchSubscriptionStream implements AsyncIterator, AsyncIterable { #private; constructor(init: WatchStreamInit); get subscriptionId(): string; get retainedCount(): number; get lastDeliveredCursor(): string | null | undefined; [Symbol.asyncIterator](): this; next(): Promise>; return(): Promise>; throw(error?: unknown): Promise>; cancel(): Promise; reconnect(freshConnection: Connection): Promise; } export {};