Adds default subscriptions for agent copilot, and any additional passed subscriptions. When the AGENTIC_WEBSOCKET toggle is ON the agenticWssWorker owns the copilot topics, so they are skipped on the old worker.
reconnectIntervalInMs in millisecond, maxReconnectAttempts in number and ws url
used to broadcast the acp messages to other tabs.
message to broadcast
This method to perform the different actions on callback response
used to unsubscribe events and clear props.
used to connect to the socket.
websocketServer uri
used to unsubscribe and disconnect to socket events.
Resolves the agentic WebSocket base URL using a two-tier cache:
null if the REST call fails — caller must handle gracefully.Marks a HEARTBEAT_ACK as received for the given state and resets the miss counter.
mutable heartbeat state to update
log label used in the info message
Initialises or re-connects the agentic WebSocket worker.
Spawns the underlying Web Worker exactly once; subsequent calls reuse it
and only post a fresh connect frame with a freshly-read access token.
Use to initializing the web socket worker and will return the method inside the worker
AAH provider
Use to initializing the web socket worker and will return the method inside the worker
Returns whether the agentic WebSocket feature toggle is enabled.
Returns whether the heartbeat monitor logic is enabled for agent copilot websocket reconnects.
Routes messages posted by the agentic worker to the appropriate handler.
Reads this.agentId dynamically so an agent change without page reload
does not leave the worker subscribing to stale topics.
on websocket close.
callback for when error received
Handles a decoded WS frame. source identifies which socket the frame
arrived on so heartbeat state mutations stay scoped to that socket.
raw decoded message
'primary' (default) or 'agentic'
@example
onMessage(message, 'primary');
Callback method when a connection is open and ready to send and receive data
Callback method triggered when the WebSocket connection needs to be re-established. Resets the connection ID and reconnects using the stored WebSocket URI and provider ID.
Callback method when a ws reconnect attempts are completed
Callback method when a ws reconnect attempts was successful
method to parse the response
@example
const AgentAssistMessageResponse = new AgentAssistMessageResponse();
used to Reconnect to the socket.
Schedules a reconnect through the worker's exponential-backoff path. Guards against overlapping schedules. Caller should have already stopped (or be prepared to stop) the heartbeat monitor.
Method to send to websocket worker
message send to websocket
Starts a heartbeat monitor for the given state object. After HEARTBEAT_MISS_THRESHOLD consecutive missed acknowledgments, stops the monitor and calls onThreshold to trigger the appropriate reconnect action.
mutable heartbeat state (timer, ackReceived, missCount)
polling interval in milliseconds
log label used in warn/info messages
callback invoked when miss threshold is reached
Clears the heartbeat monitor interval for the given state and resets its fields.
mutable heartbeat state to clear
Subscribe to events.
Sends SUBSCRIBE frames for the two agentic copilot topics to the agentic worker.
Called on the worker's 'open' event. Each frame carries the current
access token as headers.sessionToken — the agentic gateway requires it
for re-authorisation on every command, not just the initial handshake.
Also pushes the fresh token into the worker so subsequent HEARTBEAT
frames generated inside the worker pick up the latest credential.
used to subscribe to socket events.
topic to subscribe
Tears down the agentic worker, heartbeat monitor, and URL cache. Intended for end-of-session flows (logout, agent change). Not invoked by transient error paths.
Tears down the primary WSS worker only. The agentic worker has an
independent lifecycle and is intentionally kept alive across transient
primary-socket errors. Call terminateAgenticWorker() explicitly on
logout, agent change, or toggle-off to release agentic resources.
Unsubscribe from a specific topic.
Generated using TypeDoc
web socket class for agent copilot