Description
The package is emitted as ESM, and Node 22 provides a standards-compatible globalThis.WebSocket. The conversation and bash event clients only check window.WebSocket, then attempt require('ws'). Since require is unavailable in ESM, starting either client reports that no WebSocket implementation is available.
Steps to reproduce
- Install dependencies and build the package on Node 22.
- Import
WebSocketCallbackClient from dist/events/websocket-client.js in an ESM process.
- Create a client and call
start().
node --input-type=module -e "const {WebSocketCallbackClient}=await import('./dist/events/websocket-client.js'); const client=new WebSocketCallbackClient({host:'http://127.0.0.1:9',conversationId:'test',callback:()=>{},onError:console.error}); client.start(); client.stop()"
Expected behavior
The client uses Node's global WebSocket constructor.
Actual behavior
The error callback receives WebSocket implementation not available, even though globalThis.WebSocket exists.
Environment
- Node.js 22.22.2
- Current
main
Description
The package is emitted as ESM, and Node 22 provides a standards-compatible
globalThis.WebSocket. The conversation and bash event clients only checkwindow.WebSocket, then attemptrequire('ws'). Sincerequireis unavailable in ESM, starting either client reports that no WebSocket implementation is available.Steps to reproduce
WebSocketCallbackClientfromdist/events/websocket-client.jsin an ESM process.start().node --input-type=module -e "const {WebSocketCallbackClient}=await import('./dist/events/websocket-client.js'); const client=new WebSocketCallbackClient({host:'http://127.0.0.1:9',conversationId:'test',callback:()=>{},onError:console.error}); client.start(); client.stop()"Expected behavior
The client uses Node's global
WebSocketconstructor.Actual behavior
The error callback receives
WebSocket implementation not available, even thoughglobalThis.WebSocketexists.Environment
main