@aui.io/aui-client 1.2.24 → 1.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,8 +72,14 @@ console.log('Total tasks:', userTasks.total);
72
72
  ### WebSocket - Real-time Agent Communication
73
73
 
74
74
  ```typescript
75
- // Connect to WebSocket
76
- const socket = await client.apolloWsSession.connect();
75
+ // Connect to WebSocket with authentication headers
76
+ const socket = await client.apolloWsSession.connect({
77
+ debug: false,
78
+ reconnectAttempts: 3,
79
+ headers: {
80
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
81
+ }
82
+ });
77
83
 
78
84
  // Listen for connection open
79
85
  socket.on('open', () => {
@@ -191,7 +197,13 @@ const client = new ApolloClient({
191
197
 
192
198
  // Both REST and WebSocket will use Azure endpoints
193
199
  const task = await client.controllerApi.createTask({...});
194
- const socket = await client.apolloWsSession.connect();
200
+ const socket = await client.apolloWsSession.connect({
201
+ debug: false,
202
+ reconnectAttempts: 3,
203
+ headers: {
204
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
205
+ }
206
+ });
195
207
  ```
196
208
 
197
209
  ---
@@ -346,8 +358,14 @@ async function searchProducts(userId: string, query: string) {
346
358
  const taskId = taskResponse.id;
347
359
  console.log('Created task:', taskId);
348
360
 
349
- // Step 2: Connect to WebSocket
350
- const socket = await client.apolloWsSession.connect();
361
+ // Step 2: Connect to WebSocket with authentication
362
+ const socket = await client.apolloWsSession.connect({
363
+ debug: false,
364
+ reconnectAttempts: 3,
365
+ headers: {
366
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
367
+ }
368
+ });
351
369
 
352
370
  // Step 3: Set up event handlers
353
371
  socket.on('open', () => {
@@ -489,8 +507,11 @@ const taskResponse = await client.controllerApi.createTask(
489
507
 
490
508
  ```typescript
491
509
  const socket = await client.apolloWsSession.connect({
492
- reconnectAttempts: 50, // Try to reconnect up to 50 times
493
- debug: true // Enable debug logging
510
+ debug: true, // Enable debug logging
511
+ reconnectAttempts: 50, // Try to reconnect up to 50 times
512
+ headers: {
513
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
514
+ }
494
515
  });
495
516
 
496
517
  // The WebSocket will automatically attempt to reconnect on failure
@@ -45,8 +45,8 @@ class ApolloClient {
45
45
  "x-network-api-key": _options === null || _options === void 0 ? void 0 : _options.networkApiKey,
46
46
  "X-Fern-Language": "JavaScript",
47
47
  "X-Fern-SDK-Name": "@aui.io/aui-client",
48
- "X-Fern-SDK-Version": "1.2.24",
49
- "User-Agent": "@aui.io/aui-client/1.2.24",
48
+ "X-Fern-SDK-Version": "1.2.26",
49
+ "User-Agent": "@aui.io/aui-client/1.2.26",
50
50
  "X-Fern-Runtime": core.RUNTIME.type,
51
51
  "X-Fern-Runtime-Version": core.RUNTIME.version,
52
52
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -371,13 +371,34 @@ class ReconnectingWebSocket {
371
371
  url = `${url}?${queryString}`;
372
372
  }
373
373
  }
374
- // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
375
- // Only pass protocols parameter if it has actual values
376
- if (this._protocols && this._protocols.length > 0) {
377
- this._ws = new WebSocket(url, this._protocols, options);
374
+ // FIX: Browser WebSocket doesn't support options parameter (causes "[object Object]" error)
375
+ // Detect if we're in a browser environment
376
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
377
+ if (isBrowser) {
378
+ // Browser: Can only pass URL and optionally protocols (string/array)
379
+ // Add API key to URL as query parameter for browser authentication
380
+ // Backend accepts 'network_api_key' query param (without x- prefix)
381
+ if (this._headers && this._headers["x-network-api-key"]) {
382
+ const separator = url.includes("?") ? "&" : "?";
383
+ url = `${url}${separator}network_api_key=${encodeURIComponent(this._headers["x-network-api-key"])}`;
384
+ }
385
+ // FIX: Don't pass empty protocols array
386
+ if (this._protocols && this._protocols.length > 0) {
387
+ this._ws = new WebSocket(url, this._protocols);
388
+ }
389
+ else {
390
+ this._ws = new WebSocket(url);
391
+ }
378
392
  }
379
393
  else {
380
- this._ws = new WebSocket(url, options);
394
+ // Node.js: Can pass options with headers
395
+ // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
396
+ if (this._protocols && this._protocols.length > 0) {
397
+ this._ws = new WebSocket(url, this._protocols, options);
398
+ }
399
+ else {
400
+ this._ws = new WebSocket(url, options);
401
+ }
381
402
  }
382
403
  this._ws.binaryType = this._binaryType;
383
404
  this._connectLock = false;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.2.24";
1
+ export declare const SDK_VERSION = "1.2.26";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "1.2.24";
4
+ exports.SDK_VERSION = "1.2.26";
@@ -9,8 +9,8 @@ export class ApolloClient {
9
9
  "x-network-api-key": _options === null || _options === void 0 ? void 0 : _options.networkApiKey,
10
10
  "X-Fern-Language": "JavaScript",
11
11
  "X-Fern-SDK-Name": "@aui.io/aui-client",
12
- "X-Fern-SDK-Version": "1.2.24",
13
- "User-Agent": "@aui.io/aui-client/1.2.24",
12
+ "X-Fern-SDK-Version": "1.2.26",
13
+ "User-Agent": "@aui.io/aui-client/1.2.26",
14
14
  "X-Fern-Runtime": core.RUNTIME.type,
15
15
  "X-Fern-Runtime-Version": core.RUNTIME.version,
16
16
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -335,13 +335,34 @@ export class ReconnectingWebSocket {
335
335
  url = `${url}?${queryString}`;
336
336
  }
337
337
  }
338
- // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
339
- // Only pass protocols parameter if it has actual values
340
- if (this._protocols && this._protocols.length > 0) {
341
- this._ws = new WebSocket(url, this._protocols, options);
338
+ // FIX: Browser WebSocket doesn't support options parameter (causes "[object Object]" error)
339
+ // Detect if we're in a browser environment
340
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
341
+ if (isBrowser) {
342
+ // Browser: Can only pass URL and optionally protocols (string/array)
343
+ // Add API key to URL as query parameter for browser authentication
344
+ // Backend accepts 'network_api_key' query param (without x- prefix)
345
+ if (this._headers && this._headers["x-network-api-key"]) {
346
+ const separator = url.includes("?") ? "&" : "?";
347
+ url = `${url}${separator}network_api_key=${encodeURIComponent(this._headers["x-network-api-key"])}`;
348
+ }
349
+ // FIX: Don't pass empty protocols array
350
+ if (this._protocols && this._protocols.length > 0) {
351
+ this._ws = new WebSocket(url, this._protocols);
352
+ }
353
+ else {
354
+ this._ws = new WebSocket(url);
355
+ }
342
356
  }
343
357
  else {
344
- this._ws = new WebSocket(url, options);
358
+ // Node.js: Can pass options with headers
359
+ // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
360
+ if (this._protocols && this._protocols.length > 0) {
361
+ this._ws = new WebSocket(url, this._protocols, options);
362
+ }
363
+ else {
364
+ this._ws = new WebSocket(url, options);
365
+ }
345
366
  }
346
367
  this._ws.binaryType = this._binaryType;
347
368
  this._connectLock = false;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.2.24";
1
+ export declare const SDK_VERSION = "1.2.26";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.2.24";
1
+ export const SDK_VERSION = "1.2.26";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aui.io/aui-client",
3
- "version": "1.2.24",
3
+ "version": "1.2.26",
4
4
  "private": false,
5
5
  "repository": "github:aui-io/aui-client-typescript",
6
6
  "type": "commonjs",