Skip to content

Class: WebSocketClient

@kortexya/reasoninglayer


@kortexya/reasoninglayer / WebSocketClient

Class: WebSocketClient

Defined in: src/websocket.ts:221

WebSocket client for real-time event subscriptions.

Remarks

Dependency rule: imports ONLY from config.ts + errors.ts (same level as http.ts).

Constructs WebSocket URLs from the base HTTP URL by replacing the protocol (http -> ws, https -> wss) and appending the tenant ID as a query parameter.

Example

const wsClient = new WebSocketClient(resolvedConfig);
const conn = wsClient.connect('/api/v1/cognitive/agents/events', {
agent_id: 'some-uuid',
});
conn.onMessage((event) => console.log(event));
// ... later
conn.close();

Constructors

Constructor

new WebSocketClient(config): WebSocketClient

Defined in: src/websocket.ts:224

Parameters

config

ResolvedConfig

Returns

WebSocketClient

Methods

connect()

connect(path, params?): WebSocketConnection

Defined in: src/websocket.ts:235

Open a WebSocket connection to the given path.

Parameters

path

string

API path (e.g., /api/v1/cognitive/agents/events).

params?

Record<string, string>

Additional query parameters (appended after tenant_id).

Returns

WebSocketConnection

A new WebSocketConnection with auto-reconnect.