createVoiceGateway from @agentium/transport connects Socket.IO clients to registered VoiceAgent instances. It reserves sessions before asynchronous setup, cancels late connections after disconnect, and bounds queued audio.
Authenticate connections
When you configureauthMiddleware, verify credentials and populate socket.data.auth with { userId, tenantId?, sessionId? }. Client user/session/API-key overrides are ignored in authenticated mode; missing trusted identity rejects setup. Keep provider credentials on the server.
The text gateway has a separate required security mode. Do not assume configuring one gateway secures the other.
Client event contract
Sequence acknowledgement and playback confirmation serve different purposes. Only send played-character offsets when backed by audio/text alignment. Send playback completion even if every frame has already been acknowledged.