import { InworldPacket as ProtoPacket } from '../../proto/ai/inworld/packets/packets.pb'; import { Awaitable, InternalClientConfiguration } from '../common/data_structures'; import { InworldPacket } from '../entities/inworld_packet.entity'; import { SessionToken } from '../entities/session_token.entity'; interface ConnectionProps { config?: InternalClientConfiguration; onDisconnect?: () => Awaitable; onReady?: () => Awaitable; onError?: (err: Event | Error) => Awaitable; onMessage?: (packet: ProtoPacket) => Awaitable; } interface OpenConnectionProps { session: SessionToken; convertPacketFromProto: (proto: ProtoPacket) => InworldPacketT; packets?: QueueItem[]; } export interface QueueItem { getPacket: () => ProtoPacket; afterWriting?: (packet: InworldPacketT) => void; beforeWriting?: (packet: InworldPacketT) => Promise; } export interface Connection { close(): void; isActive: () => boolean; open(props: OpenConnectionProps): Promise; write(item: QueueItem): void; } export declare class WebSocketConnection implements Connection { private connectionProps; private ws; private packetQueue; private convertPacketFromProto; constructor(props: ConnectionProps); isActive(): boolean; open({ session, packets, convertPacketFromProto, }: OpenConnectionProps): Promise; close(): void; write(item: QueueItem): Promise; private createWebSocket; private onMessage; private onReady; } export {};