Skip to main content

setupAgenticWSHandlers

@nuclia/core


@nuclia/core / setupAgenticWSHandlers

Function: setupAgenticWSHandlers()

setupAgenticWSHandlers(ws, message, subject, onUnexpectedClose?, closeOnDone?): void

Defined in: libs/sdk-core/src/lib/db/retrieval-agent/agentic-websocket.ts:24

Sets up the onopen / onmessage / onerror / onclose handlers on an already-created WebSocket.

Shared by RetrievalAgent._interactThroughWs() and KnowledgeBox.askViaWS(). Both callers own the Subject and the WebSocket; this function only wires the handlers.

Parameters​

ws​

WebSocket

The WebSocket instance to attach handlers to.

message​

InteractionRequest

The initial message sent on open.

subject​

Subject<IErrorResponse | AragResponse>

The Subject that receives parsed AragAnswer emissions.

onUnexpectedClose?​

(event, lastMessage?) => void

Called when the socket closes with a non-1000 code before receiving a DONE operation. The caller decides whether to reconnect (RetrievalAgent) or emit an error and complete (KnowledgeBox).

closeOnDone?​

boolean = true

Returns​

void