Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

toWebSocketStream.md

43 lines947 Bytes

function toWebSocketStream<TOffset>(
   socket, 
   request, 
   init): void;

Defined in: packages/ai/src/stream-to-websocket.ts:115

Run a full-duplex, conversation-scoped chat over an already-accepted server socket. Each inbound RunAgentInput frame starts one chat() turn (via onRun) whose chunks are pumped back as frames; the socket stays open across turns (pending client-tool resubmit, next user message) until the client closes it or the idle timeout fires. An abort control frame aborts only its turn.

Type Parameters

TOffset

TOffset extends string = string

Parameters

socket

WebSocketLike

request

Request

init

WebSocketStreamInit<TOffset>

Returns

void