BotFramework-DirectLineJS is a client library for the Microsoft Bot Framework Direct Line 3.0 protocol. It enables JavaScript/TypeScript applications to communicate with bots via both REST polling and WebSocket connections. The library implements a sophisticated state machine for connection management (Uninitialized, Connecting, Online, ExpiredToken, FailedToConnect, Ended) with automatic reconnection, token refresh, and retry logic. It uses RxJS observables for handling asynchronous operations and activity streams. The architecture is modular with separate implementations for standard DirectLine and DirectLineStreaming (WebSocket-based) connections, plus utility modules for filename deduplication, iframe detection, and network-aware WebSockets.