@coze/realtime-api 1.0.4-beta.2 → 1.0.5

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/dist/umd/index.js CHANGED
@@ -7,10 +7,17 @@
7
7
  })(self, ()=>(()=>{
8
8
  "use strict";
9
9
  var __webpack_modules__ = {
10
+ "../../common/temp/default/node_modules/.pnpm/ws@8.18.0/node_modules/ws/browser.js": function(module1) {
11
+ module1.exports = function() {
12
+ throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object");
13
+ };
14
+ },
10
15
  "?666e": function() {
11
16
  /* (ignored) */ },
12
17
  "?79fd": function() {
13
18
  /* (ignored) */ },
19
+ "?8dee": function() {
20
+ /* (ignored) */ },
14
21
  "?9050": function() {
15
22
  /* (ignored) */ }
16
23
  };
@@ -247,8 +254,6 @@
247
254
  if ((null == error ? void 0 : error.detail) && msg !== error.detail) list.push(`detail: ${error.detail}`);
248
255
  const logId = (null == error ? void 0 : error.logid) || (null == headers ? void 0 : headers['x-tt-logid']);
249
256
  if (logId) list.push(`logid: ${logId}`);
250
- const help_doc = null == error ? void 0 : error.help_doc;
251
- if (help_doc) list.push(`help doc: ${help_doc}`);
252
257
  return list.join(', ');
253
258
  }
254
259
  if (status) return `http status code: ${status} (no body)`;
@@ -271,16 +276,15 @@
271
276
  return new error_APIError(status, error, message, headers);
272
277
  }
273
278
  constructor(status, error, message, headers){
274
- var _error_error, _error_error1;
279
+ var _error_detail, _error_error;
275
280
  super(`${error_APIError.makeMessage(status, error, message, headers)}`);
276
281
  this.status = status;
277
282
  this.headers = headers;
278
- this.logid = null == headers ? void 0 : headers['x-tt-logid'];
283
+ this.logid = (null == error ? void 0 : null === (_error_detail = error.detail) || void 0 === _error_detail ? void 0 : _error_detail.logid) || (null == headers ? void 0 : headers['x-tt-logid']);
279
284
  // this.error = error;
280
285
  this.code = null == error ? void 0 : error.code;
281
286
  this.msg = null == error ? void 0 : error.msg;
282
287
  this.detail = null == error ? void 0 : null === (_error_error = error.error) || void 0 === _error_error ? void 0 : _error_error.detail;
283
- this.help_doc = null == error ? void 0 : null === (_error_error1 = error.error) || void 0 === _error_error1 ? void 0 : _error_error1.help_doc;
284
288
  this.rawError = error;
285
289
  }
286
290
  }
@@ -3932,10 +3936,705 @@
3932
3936
  return response.data;
3933
3937
  }
3934
3938
  }
3939
+ class chat_Chat extends APIResource {
3940
+ async create(botId, options) {
3941
+ const apiUrl = `/v1/chat?bot_id=${botId}`;
3942
+ return await this._client.makeWebsocket(apiUrl, options);
3943
+ }
3944
+ }
3945
+ class transcriptions_Transcriptions extends APIResource {
3946
+ async create(options) {
3947
+ const apiUrl = '/v1/audio/transcriptions';
3948
+ return await this._client.makeWebsocket(apiUrl, options);
3949
+ }
3950
+ }
3951
+ class speech_Speech extends APIResource {
3952
+ async create(options) {
3953
+ const apiUrl = '/v1/audio/speech';
3954
+ return await this._client.makeWebsocket(apiUrl, options);
3955
+ }
3956
+ }
3957
+ class websockets_audio_Audio extends APIResource {
3958
+ constructor(...args){
3959
+ super(...args), this.speech = new speech_Speech(this._client), this.transcriptions = new transcriptions_Transcriptions(this._client);
3960
+ }
3961
+ }
3962
+ class Websockets extends APIResource {
3963
+ constructor(...args){
3964
+ super(...args), this.audio = new websockets_audio_Audio(this._client), this.chat = new chat_Chat(this._client);
3965
+ }
3966
+ }
3967
+ // EXTERNAL MODULE: ../../common/temp/default/node_modules/.pnpm/ws@8.18.0/node_modules/ws/browser.js
3968
+ var ws_browser = __webpack_require__("../../common/temp/default/node_modules/.pnpm/ws@8.18.0/node_modules/ws/browser.js");
3969
+ var browser_default = /*#__PURE__*/ __webpack_require__.n(ws_browser);
3970
+ /*! *****************************************************************************
3971
+ Copyright (c) Microsoft Corporation. All rights reserved.
3972
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
3973
+ this file except in compliance with the License. You may obtain a copy of the
3974
+ License at http://www.apache.org/licenses/LICENSE-2.0
3975
+
3976
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3977
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
3978
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
3979
+ MERCHANTABLITY OR NON-INFRINGEMENT.
3980
+
3981
+ See the Apache Version 2.0 License for specific language governing permissions
3982
+ and limitations under the License.
3983
+ ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) {
3984
+ extendStatics = Object.setPrototypeOf || ({
3985
+ __proto__: []
3986
+ }) instanceof Array && function(d, b) {
3987
+ d.__proto__ = b;
3988
+ } || function(d, b) {
3989
+ for(var p in b)if (b.hasOwnProperty(p)) d[p] = b[p];
3990
+ };
3991
+ return extendStatics(d, b);
3992
+ };
3993
+ function __extends(d, b) {
3994
+ extendStatics(d, b);
3995
+ function __() {
3996
+ this.constructor = d;
3997
+ }
3998
+ d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
3999
+ }
4000
+ function __values(o) {
4001
+ var m = "function" == typeof Symbol && o[Symbol.iterator], i = 0;
4002
+ if (m) return m.call(o);
4003
+ return {
4004
+ next: function() {
4005
+ if (o && i >= o.length) o = void 0;
4006
+ return {
4007
+ value: o && o[i++],
4008
+ done: !o
4009
+ };
4010
+ }
4011
+ };
4012
+ }
4013
+ function __read(o, n) {
4014
+ var m = "function" == typeof Symbol && o[Symbol.iterator];
4015
+ if (!m) return o;
4016
+ var i = m.call(o), r, ar = [], e;
4017
+ try {
4018
+ while((void 0 === n || n-- > 0) && !(r = i.next()).done)ar.push(r.value);
4019
+ } catch (error) {
4020
+ e = {
4021
+ error: error
4022
+ };
4023
+ } finally{
4024
+ try {
4025
+ if (r && !r.done && (m = i["return"])) m.call(i);
4026
+ } finally{
4027
+ if (e) throw e.error;
4028
+ }
4029
+ }
4030
+ return ar;
4031
+ }
4032
+ function __spread() {
4033
+ for(var ar = [], i = 0; i < arguments.length; i++)ar = ar.concat(__read(arguments[i]));
4034
+ return ar;
4035
+ }
4036
+ var reconnecting_websocket_mjs_Event = /** @class */ function() {
4037
+ function Event1(type, target) {
4038
+ this.target = target;
4039
+ this.type = type;
4040
+ }
4041
+ return Event1;
4042
+ }();
4043
+ var reconnecting_websocket_mjs_ErrorEvent = /** @class */ function(_super) {
4044
+ __extends(ErrorEvent, _super);
4045
+ function ErrorEvent(error, target) {
4046
+ var _this = _super.call(this, 'error', target) || this;
4047
+ _this.message = error.message;
4048
+ _this.error = error;
4049
+ return _this;
4050
+ }
4051
+ return ErrorEvent;
4052
+ }(reconnecting_websocket_mjs_Event);
4053
+ var reconnecting_websocket_mjs_CloseEvent = /** @class */ function(_super) {
4054
+ __extends(CloseEvent, _super);
4055
+ function CloseEvent(code, reason, target) {
4056
+ if (void 0 === code) code = 1000;
4057
+ if (void 0 === reason) reason = '';
4058
+ var _this = _super.call(this, 'close', target) || this;
4059
+ _this.wasClean = true;
4060
+ _this.code = code;
4061
+ _this.reason = reason;
4062
+ return _this;
4063
+ }
4064
+ return CloseEvent;
4065
+ }(reconnecting_websocket_mjs_Event);
4066
+ /*!
4067
+ * Reconnecting WebSocket
4068
+ * by Pedro Ladaria <pedro.ladaria@gmail.com>
4069
+ * https://github.com/pladaria/reconnecting-websocket
4070
+ * License MIT
4071
+ */ var getGlobalWebSocket = function() {
4072
+ if ('undefined' != typeof WebSocket) // @ts-ignore
4073
+ return WebSocket;
4074
+ };
4075
+ /**
4076
+ * Returns true if given argument looks like a WebSocket class
4077
+ */ var isWebSocket = function(w) {
4078
+ return void 0 !== w && !!w && 2 === w.CLOSING;
4079
+ };
4080
+ var DEFAULT = {
4081
+ maxReconnectionDelay: 10000,
4082
+ minReconnectionDelay: 1000 + 4000 * Math.random(),
4083
+ minUptime: 5000,
4084
+ reconnectionDelayGrowFactor: 1.3,
4085
+ connectionTimeout: 4000,
4086
+ maxRetries: 1 / 0,
4087
+ maxEnqueuedMessages: 1 / 0,
4088
+ startClosed: false,
4089
+ debug: false
4090
+ };
4091
+ var reconnecting_websocket_mjs_ReconnectingWebSocket = /** @class */ function() {
4092
+ function ReconnectingWebSocket(url, protocols, options) {
4093
+ var _this = this;
4094
+ if (void 0 === options) options = {};
4095
+ this._listeners = {
4096
+ error: [],
4097
+ message: [],
4098
+ open: [],
4099
+ close: []
4100
+ };
4101
+ this._retryCount = -1;
4102
+ this._shouldReconnect = true;
4103
+ this._connectLock = false;
4104
+ this._binaryType = 'blob';
4105
+ this._closeCalled = false;
4106
+ this._messageQueue = [];
4107
+ /**
4108
+ * An event listener to be called when the WebSocket connection's readyState changes to CLOSED
4109
+ */ this.onclose = null;
4110
+ /**
4111
+ * An event listener to be called when an error occurs
4112
+ */ this.onerror = null;
4113
+ /**
4114
+ * An event listener to be called when a message is received from the server
4115
+ */ this.onmessage = null;
4116
+ /**
4117
+ * An event listener to be called when the WebSocket connection's readyState changes to OPEN;
4118
+ * this indicates that the connection is ready to send and receive data
4119
+ */ this.onopen = null;
4120
+ this._handleOpen = function(event) {
4121
+ _this._debug('open event');
4122
+ var _a = _this._options.minUptime, minUptime = void 0 === _a ? DEFAULT.minUptime : _a;
4123
+ clearTimeout(_this._connectTimeout);
4124
+ _this._uptimeTimeout = setTimeout(function() {
4125
+ return _this._acceptOpen();
4126
+ }, minUptime);
4127
+ _this._ws.binaryType = _this._binaryType;
4128
+ // send enqueued messages (messages sent before websocket open event)
4129
+ _this._messageQueue.forEach(function(message) {
4130
+ return _this._ws.send(message);
4131
+ });
4132
+ _this._messageQueue = [];
4133
+ if (_this.onopen) _this.onopen(event);
4134
+ _this._listeners.open.forEach(function(listener) {
4135
+ return _this._callEventListener(event, listener);
4136
+ });
4137
+ };
4138
+ this._handleMessage = function(event) {
4139
+ _this._debug('message event');
4140
+ if (_this.onmessage) _this.onmessage(event);
4141
+ _this._listeners.message.forEach(function(listener) {
4142
+ return _this._callEventListener(event, listener);
4143
+ });
4144
+ };
4145
+ this._handleError = function(event) {
4146
+ _this._debug('error event', event.message);
4147
+ _this._disconnect(void 0, 'TIMEOUT' === event.message ? 'timeout' : void 0);
4148
+ if (_this.onerror) _this.onerror(event);
4149
+ _this._debug('exec error listeners');
4150
+ _this._listeners.error.forEach(function(listener) {
4151
+ return _this._callEventListener(event, listener);
4152
+ });
4153
+ _this._connect();
4154
+ };
4155
+ this._handleClose = function(event) {
4156
+ _this._debug('close event');
4157
+ _this._clearTimeouts();
4158
+ if (_this._shouldReconnect) _this._connect();
4159
+ if (_this.onclose) _this.onclose(event);
4160
+ _this._listeners.close.forEach(function(listener) {
4161
+ return _this._callEventListener(event, listener);
4162
+ });
4163
+ };
4164
+ this._url = url;
4165
+ this._protocols = protocols;
4166
+ this._options = options;
4167
+ if (this._options.startClosed) this._shouldReconnect = false;
4168
+ this._connect();
4169
+ }
4170
+ Object.defineProperty(ReconnectingWebSocket, "CONNECTING", {
4171
+ get: function() {
4172
+ return 0;
4173
+ },
4174
+ enumerable: true,
4175
+ configurable: true
4176
+ });
4177
+ Object.defineProperty(ReconnectingWebSocket, "OPEN", {
4178
+ get: function() {
4179
+ return 1;
4180
+ },
4181
+ enumerable: true,
4182
+ configurable: true
4183
+ });
4184
+ Object.defineProperty(ReconnectingWebSocket, "CLOSING", {
4185
+ get: function() {
4186
+ return 2;
4187
+ },
4188
+ enumerable: true,
4189
+ configurable: true
4190
+ });
4191
+ Object.defineProperty(ReconnectingWebSocket, "CLOSED", {
4192
+ get: function() {
4193
+ return 3;
4194
+ },
4195
+ enumerable: true,
4196
+ configurable: true
4197
+ });
4198
+ Object.defineProperty(ReconnectingWebSocket.prototype, "CONNECTING", {
4199
+ get: function() {
4200
+ return ReconnectingWebSocket.CONNECTING;
4201
+ },
4202
+ enumerable: true,
4203
+ configurable: true
4204
+ });
4205
+ Object.defineProperty(ReconnectingWebSocket.prototype, "OPEN", {
4206
+ get: function() {
4207
+ return ReconnectingWebSocket.OPEN;
4208
+ },
4209
+ enumerable: true,
4210
+ configurable: true
4211
+ });
4212
+ Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSING", {
4213
+ get: function() {
4214
+ return ReconnectingWebSocket.CLOSING;
4215
+ },
4216
+ enumerable: true,
4217
+ configurable: true
4218
+ });
4219
+ Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSED", {
4220
+ get: function() {
4221
+ return ReconnectingWebSocket.CLOSED;
4222
+ },
4223
+ enumerable: true,
4224
+ configurable: true
4225
+ });
4226
+ Object.defineProperty(ReconnectingWebSocket.prototype, "binaryType", {
4227
+ get: function() {
4228
+ return this._ws ? this._ws.binaryType : this._binaryType;
4229
+ },
4230
+ set: function(value) {
4231
+ this._binaryType = value;
4232
+ if (this._ws) this._ws.binaryType = value;
4233
+ },
4234
+ enumerable: true,
4235
+ configurable: true
4236
+ });
4237
+ Object.defineProperty(ReconnectingWebSocket.prototype, "retryCount", {
4238
+ /**
4239
+ * Returns the number or connection retries
4240
+ */ get: function() {
4241
+ return Math.max(this._retryCount, 0);
4242
+ },
4243
+ enumerable: true,
4244
+ configurable: true
4245
+ });
4246
+ Object.defineProperty(ReconnectingWebSocket.prototype, "bufferedAmount", {
4247
+ /**
4248
+ * The number of bytes of data that have been queued using calls to send() but not yet
4249
+ * transmitted to the network. This value resets to zero once all queued data has been sent.
4250
+ * This value does not reset to zero when the connection is closed; if you keep calling send(),
4251
+ * this will continue to climb. Read only
4252
+ */ get: function() {
4253
+ var bytes = this._messageQueue.reduce(function(acc, message) {
4254
+ if ('string' == typeof message) acc += message.length; // not byte size
4255
+ else if (message instanceof Blob) acc += message.size;
4256
+ else acc += message.byteLength;
4257
+ return acc;
4258
+ }, 0);
4259
+ return bytes + (this._ws ? this._ws.bufferedAmount : 0);
4260
+ },
4261
+ enumerable: true,
4262
+ configurable: true
4263
+ });
4264
+ Object.defineProperty(ReconnectingWebSocket.prototype, "extensions", {
4265
+ /**
4266
+ * The extensions selected by the server. This is currently only the empty string or a list of
4267
+ * extensions as negotiated by the connection
4268
+ */ get: function() {
4269
+ return this._ws ? this._ws.extensions : '';
4270
+ },
4271
+ enumerable: true,
4272
+ configurable: true
4273
+ });
4274
+ Object.defineProperty(ReconnectingWebSocket.prototype, "protocol", {
4275
+ /**
4276
+ * A string indicating the name of the sub-protocol the server selected;
4277
+ * this will be one of the strings specified in the protocols parameter when creating the
4278
+ * WebSocket object
4279
+ */ get: function() {
4280
+ return this._ws ? this._ws.protocol : '';
4281
+ },
4282
+ enumerable: true,
4283
+ configurable: true
4284
+ });
4285
+ Object.defineProperty(ReconnectingWebSocket.prototype, "readyState", {
4286
+ /**
4287
+ * The current state of the connection; this is one of the Ready state constants
4288
+ */ get: function() {
4289
+ if (this._ws) return this._ws.readyState;
4290
+ return this._options.startClosed ? ReconnectingWebSocket.CLOSED : ReconnectingWebSocket.CONNECTING;
4291
+ },
4292
+ enumerable: true,
4293
+ configurable: true
4294
+ });
4295
+ Object.defineProperty(ReconnectingWebSocket.prototype, "url", {
4296
+ /**
4297
+ * The URL as resolved by the constructor
4298
+ */ get: function() {
4299
+ return this._ws ? this._ws.url : '';
4300
+ },
4301
+ enumerable: true,
4302
+ configurable: true
4303
+ });
4304
+ /**
4305
+ * Closes the WebSocket connection or connection attempt, if any. If the connection is already
4306
+ * CLOSED, this method does nothing
4307
+ */ ReconnectingWebSocket.prototype.close = function(code, reason) {
4308
+ if (void 0 === code) code = 1000;
4309
+ this._closeCalled = true;
4310
+ this._shouldReconnect = false;
4311
+ this._clearTimeouts();
4312
+ if (!this._ws) {
4313
+ this._debug('close enqueued: no ws instance');
4314
+ return;
4315
+ }
4316
+ if (this._ws.readyState === this.CLOSED) {
4317
+ this._debug('close: already closed');
4318
+ return;
4319
+ }
4320
+ this._ws.close(code, reason);
4321
+ };
4322
+ /**
4323
+ * Closes the WebSocket connection or connection attempt and connects again.
4324
+ * Resets retry counter;
4325
+ */ ReconnectingWebSocket.prototype.reconnect = function(code, reason) {
4326
+ this._shouldReconnect = true;
4327
+ this._closeCalled = false;
4328
+ this._retryCount = -1;
4329
+ if (this._ws && this._ws.readyState !== this.CLOSED) {
4330
+ this._disconnect(code, reason);
4331
+ this._connect();
4332
+ } else this._connect();
4333
+ };
4334
+ /**
4335
+ * Enqueue specified data to be transmitted to the server over the WebSocket connection
4336
+ */ ReconnectingWebSocket.prototype.send = function(data) {
4337
+ if (this._ws && this._ws.readyState === this.OPEN) {
4338
+ this._debug('send', data);
4339
+ this._ws.send(data);
4340
+ } else {
4341
+ var _a = this._options.maxEnqueuedMessages, maxEnqueuedMessages = void 0 === _a ? DEFAULT.maxEnqueuedMessages : _a;
4342
+ if (this._messageQueue.length < maxEnqueuedMessages) {
4343
+ this._debug('enqueue', data);
4344
+ this._messageQueue.push(data);
4345
+ }
4346
+ }
4347
+ };
4348
+ /**
4349
+ * Register an event handler of a specific event type
4350
+ */ ReconnectingWebSocket.prototype.addEventListener = function(type, listener) {
4351
+ if (this._listeners[type]) // @ts-ignore
4352
+ this._listeners[type].push(listener);
4353
+ };
4354
+ ReconnectingWebSocket.prototype.dispatchEvent = function(event) {
4355
+ var e_1, _a;
4356
+ var listeners = this._listeners[event.type];
4357
+ if (listeners) try {
4358
+ for(var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()){
4359
+ var listener = listeners_1_1.value;
4360
+ this._callEventListener(event, listener);
4361
+ }
4362
+ } catch (e_1_1) {
4363
+ e_1 = {
4364
+ error: e_1_1
4365
+ };
4366
+ } finally{
4367
+ try {
4368
+ if (listeners_1_1 && !listeners_1_1.done && (_a = listeners_1.return)) _a.call(listeners_1);
4369
+ } finally{
4370
+ if (e_1) throw e_1.error;
4371
+ }
4372
+ }
4373
+ return true;
4374
+ };
4375
+ /**
4376
+ * Removes an event listener
4377
+ */ ReconnectingWebSocket.prototype.removeEventListener = function(type, listener) {
4378
+ if (this._listeners[type]) // @ts-ignore
4379
+ this._listeners[type] = this._listeners[type].filter(function(l) {
4380
+ return l !== listener;
4381
+ });
4382
+ };
4383
+ ReconnectingWebSocket.prototype._debug = function() {
4384
+ var args = [];
4385
+ for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i];
4386
+ if (this._options.debug) // not using spread because compiled version uses Symbols
4387
+ // tslint:disable-next-line
4388
+ console.log.apply(console, __spread([
4389
+ 'RWS>'
4390
+ ], args));
4391
+ };
4392
+ ReconnectingWebSocket.prototype._getNextDelay = function() {
4393
+ var _a = this._options, _b = _a.reconnectionDelayGrowFactor, reconnectionDelayGrowFactor = void 0 === _b ? DEFAULT.reconnectionDelayGrowFactor : _b, _c = _a.minReconnectionDelay, minReconnectionDelay = void 0 === _c ? DEFAULT.minReconnectionDelay : _c, _d = _a.maxReconnectionDelay, maxReconnectionDelay = void 0 === _d ? DEFAULT.maxReconnectionDelay : _d;
4394
+ var delay = 0;
4395
+ if (this._retryCount > 0) {
4396
+ delay = minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, this._retryCount - 1);
4397
+ if (delay > maxReconnectionDelay) delay = maxReconnectionDelay;
4398
+ }
4399
+ this._debug('next delay', delay);
4400
+ return delay;
4401
+ };
4402
+ ReconnectingWebSocket.prototype._wait = function() {
4403
+ var _this = this;
4404
+ return new Promise(function(resolve) {
4405
+ setTimeout(resolve, _this._getNextDelay());
4406
+ });
4407
+ };
4408
+ ReconnectingWebSocket.prototype._getNextUrl = function(urlProvider) {
4409
+ if ('string' == typeof urlProvider) return Promise.resolve(urlProvider);
4410
+ if ('function' == typeof urlProvider) {
4411
+ var url = urlProvider();
4412
+ if ('string' == typeof url) return Promise.resolve(url);
4413
+ if (!!url.then) return url;
4414
+ }
4415
+ throw Error('Invalid URL');
4416
+ };
4417
+ ReconnectingWebSocket.prototype._connect = function() {
4418
+ var _this = this;
4419
+ if (this._connectLock || !this._shouldReconnect) return;
4420
+ this._connectLock = true;
4421
+ var _a = this._options, _b = _a.maxRetries, maxRetries = void 0 === _b ? DEFAULT.maxRetries : _b, _c = _a.connectionTimeout, connectionTimeout = void 0 === _c ? DEFAULT.connectionTimeout : _c, _d = _a.WebSocket, WebSocket1 = void 0 === _d ? getGlobalWebSocket() : _d;
4422
+ if (this._retryCount >= maxRetries) {
4423
+ this._debug('max retries reached', this._retryCount, '>=', maxRetries);
4424
+ return;
4425
+ }
4426
+ this._retryCount++;
4427
+ this._debug('connect', this._retryCount);
4428
+ this._removeListeners();
4429
+ if (!isWebSocket(WebSocket1)) throw Error('No valid WebSocket class provided');
4430
+ this._wait().then(function() {
4431
+ return _this._getNextUrl(_this._url);
4432
+ }).then(function(url) {
4433
+ // close could be called before creating the ws
4434
+ if (_this._closeCalled) return;
4435
+ _this._debug('connect', {
4436
+ url: url,
4437
+ protocols: _this._protocols
4438
+ });
4439
+ _this._ws = _this._protocols ? new WebSocket1(url, _this._protocols) : new WebSocket1(url);
4440
+ _this._ws.binaryType = _this._binaryType;
4441
+ _this._connectLock = false;
4442
+ _this._addListeners();
4443
+ _this._connectTimeout = setTimeout(function() {
4444
+ return _this._handleTimeout();
4445
+ }, connectionTimeout);
4446
+ });
4447
+ };
4448
+ ReconnectingWebSocket.prototype._handleTimeout = function() {
4449
+ this._debug('timeout event');
4450
+ this._handleError(new reconnecting_websocket_mjs_ErrorEvent(Error('TIMEOUT'), this));
4451
+ };
4452
+ ReconnectingWebSocket.prototype._disconnect = function(code, reason) {
4453
+ if (void 0 === code) code = 1000;
4454
+ this._clearTimeouts();
4455
+ if (!this._ws) return;
4456
+ this._removeListeners();
4457
+ try {
4458
+ this._ws.close(code, reason);
4459
+ this._handleClose(new reconnecting_websocket_mjs_CloseEvent(code, reason, this));
4460
+ } catch (error) {
4461
+ // ignore
4462
+ }
4463
+ };
4464
+ ReconnectingWebSocket.prototype._acceptOpen = function() {
4465
+ this._debug('accept open');
4466
+ this._retryCount = 0;
4467
+ };
4468
+ ReconnectingWebSocket.prototype._callEventListener = function(event, listener) {
4469
+ if ('handleEvent' in listener) // @ts-ignore
4470
+ listener.handleEvent(event);
4471
+ else // @ts-ignore
4472
+ listener(event);
4473
+ };
4474
+ ReconnectingWebSocket.prototype._removeListeners = function() {
4475
+ if (!this._ws) return;
4476
+ this._debug('removeListeners');
4477
+ this._ws.removeEventListener('open', this._handleOpen);
4478
+ this._ws.removeEventListener('close', this._handleClose);
4479
+ this._ws.removeEventListener('message', this._handleMessage);
4480
+ // @ts-ignore
4481
+ this._ws.removeEventListener('error', this._handleError);
4482
+ };
4483
+ ReconnectingWebSocket.prototype._addListeners = function() {
4484
+ if (!this._ws) return;
4485
+ this._debug('addListeners');
4486
+ this._ws.addEventListener('open', this._handleOpen);
4487
+ this._ws.addEventListener('close', this._handleClose);
4488
+ this._ws.addEventListener('message', this._handleMessage);
4489
+ // @ts-ignore
4490
+ this._ws.addEventListener('error', this._handleError);
4491
+ };
4492
+ ReconnectingWebSocket.prototype._clearTimeouts = function() {
4493
+ clearTimeout(this._connectTimeout);
4494
+ clearTimeout(this._uptimeTimeout);
4495
+ };
4496
+ return ReconnectingWebSocket;
4497
+ }();
4498
+ /* ESM default export */ const reconnecting_websocket_mjs = reconnecting_websocket_mjs_ReconnectingWebSocket;
4499
+ // Common types (not exported)
4500
+ // Keep all existing exports but use the base types where applicable
4501
+ var types_WebsocketsEventType = /*#__PURE__*/ function(WebsocketsEventType) {
4502
+ // Common
4503
+ /** SDK error */ WebsocketsEventType["CLIENT_ERROR"] = "client_error";
4504
+ /** Connection closed */ WebsocketsEventType["CLOSED"] = "closed";
4505
+ // Error
4506
+ /** Received error event */ WebsocketsEventType["ERROR"] = "error";
4507
+ // v1/audio/speech
4508
+ /** Send text to server */ WebsocketsEventType["INPUT_TEXT_BUFFER_APPEND"] = "input_text_buffer.append";
4509
+ /** No text to send, after audio all received, can close connection */ WebsocketsEventType["INPUT_TEXT_BUFFER_COMPLETE"] = "input_text_buffer.complete";
4510
+ /** Send speech config to server */ WebsocketsEventType["SPEECH_UPDATE"] = "speech.update";
4511
+ /** Received `speech.updated` event */ WebsocketsEventType["SPEECH_UPDATED"] = "speech.updated";
4512
+ /** After speech created */ WebsocketsEventType["SPEECH_CREATED"] = "speech.created";
4513
+ /** Received `input_text_buffer.complete` event */ WebsocketsEventType["INPUT_TEXT_BUFFER_COMPLETED"] = "input_text_buffer.completed";
4514
+ /** Received `speech.update` event */ WebsocketsEventType["SPEECH_AUDIO_UPDATE"] = "speech.audio.update";
4515
+ /** All audio received, can close connection */ WebsocketsEventType["SPEECH_AUDIO_COMPLETED"] = "speech.audio.completed";
4516
+ // v1/audio/transcriptions
4517
+ /** Send audio to server */ WebsocketsEventType["INPUT_AUDIO_BUFFER_APPEND"] = "input_audio_buffer.append";
4518
+ /** No audio to send, after text all received, can close connection */ WebsocketsEventType["INPUT_AUDIO_BUFFER_COMPLETE"] = "input_audio_buffer.complete";
4519
+ /** Send transcriptions config to server */ WebsocketsEventType["TRANSCRIPTIONS_UPDATE"] = "transcriptions.update";
4520
+ /** Send `input_audio_buffer.clear` event */ WebsocketsEventType["INPUT_AUDIO_BUFFER_CLEAR"] = "input_audio_buffer.clear";
4521
+ /** After transcriptions created */ WebsocketsEventType["TRANSCRIPTIONS_CREATED"] = "transcriptions.created";
4522
+ /** Received `input_audio_buffer.complete` event */ WebsocketsEventType["INPUT_AUDIO_BUFFER_COMPLETED"] = "input_audio_buffer.completed";
4523
+ /** Received `transcriptions.update` event */ WebsocketsEventType["TRANSCRIPTIONS_MESSAGE_UPDATE"] = "transcriptions.message.update";
4524
+ /** All audio received, can close connection */ WebsocketsEventType["TRANSCRIPTIONS_MESSAGE_COMPLETED"] = "transcriptions.message.completed";
4525
+ /** Received `input_audio_buffer.cleared` event */ WebsocketsEventType["INPUT_AUDIO_BUFFER_CLEARED"] = "input_audio_buffer.cleared";
4526
+ /** Received `transcriptions.updated` event */ WebsocketsEventType["TRANSCRIPTIONS_UPDATED"] = "transcriptions.updated";
4527
+ // v1/chat
4528
+ /** Send chat config to server */ WebsocketsEventType["CHAT_UPDATE"] = "chat.update";
4529
+ /** Send tool outputs to server */ WebsocketsEventType["CONVERSATION_CHAT_SUBMIT_TOOL_OUTPUTS"] = "conversation.chat.submit_tool_outputs";
4530
+ /** After chat created */ WebsocketsEventType["CHAT_CREATED"] = "chat.created";
4531
+ /** After chat updated */ WebsocketsEventType["CHAT_UPDATED"] = "chat.updated";
4532
+ /** Audio AST completed, chat started */ WebsocketsEventType["CONVERSATION_CHAT_CREATED"] = "conversation.chat.created";
4533
+ /** Message created */ WebsocketsEventType["CONVERSATION_MESSAGE_CREATE"] = "conversation.message.create";
4534
+ /** Clear conversation */ WebsocketsEventType["CONVERSATION_CLEAR"] = "conversation.clear";
4535
+ /** Chat in progress */ WebsocketsEventType["CONVERSATION_CHAT_IN_PROGRESS"] = "conversation.chat.in_progress";
4536
+ /** Get agent text message update */ WebsocketsEventType["CONVERSATION_MESSAGE_DELTA"] = "conversation.message.delta";
4537
+ /** Need plugin submit */ WebsocketsEventType["CONVERSATION_CHAT_REQUIRES_ACTION"] = "conversation.chat.requires_action";
4538
+ /** Message completed */ WebsocketsEventType["CONVERSATION_MESSAGE_COMPLETED"] = "conversation.message.completed";
4539
+ /** Get agent audio message update */ WebsocketsEventType["CONVERSATION_AUDIO_DELTA"] = "conversation.audio.delta";
4540
+ /** Audio message completed */ WebsocketsEventType["CONVERSATION_AUDIO_COMPLETED"] = "conversation.audio.completed";
4541
+ /** All message received, can close connection */ WebsocketsEventType["CONVERSATION_CHAT_COMPLETED"] = "conversation.chat.completed";
4542
+ /** Chat failed */ WebsocketsEventType["CONVERSATION_CHAT_FAILED"] = "conversation.chat.failed";
4543
+ /** Received `conversation.cleared` event */ WebsocketsEventType["CONVERSATION_CLEARED"] = "conversation.cleared";
4544
+ return WebsocketsEventType;
4545
+ }({});
4546
+ class WebSocketAPI {
4547
+ // Standard WebSocket properties
4548
+ get readyState() {
4549
+ return this.rws.readyState;
4550
+ }
4551
+ // Standard WebSocket methods
4552
+ send(data) {
4553
+ return this.rws.send(JSON.stringify(data));
4554
+ }
4555
+ close(code, reason) {
4556
+ return this.rws.close(code, reason);
4557
+ }
4558
+ reconnect(code, reason) {
4559
+ return this.rws.reconnect(code, reason);
4560
+ }
4561
+ // Event listener methods
4562
+ addEventListener(type, listener) {
4563
+ this.rws.addEventListener(type, listener);
4564
+ }
4565
+ removeEventListener(type, listener) {
4566
+ this.rws.removeEventListener(type, listener);
4567
+ }
4568
+ constructor(url, options = {}){
4569
+ // Event handler methods
4570
+ this.onmessage = null;
4571
+ this.onopen = null;
4572
+ this.onclose = null;
4573
+ this.onerror = null;
4574
+ const separator = url.includes('?') ? '&' : '?';
4575
+ const { authorization } = options.headers || {};
4576
+ this.rws = new reconnecting_websocket_mjs(`${url}${separator}authorization=${authorization}`, [], {
4577
+ WebSocket: utils_isBrowser() ? window.WebSocket : class extends browser_default() {
4578
+ constructor(url2, protocols){
4579
+ super(url2, protocols, {
4580
+ headers: options.headers
4581
+ });
4582
+ }
4583
+ },
4584
+ ...options
4585
+ });
4586
+ this.rws.addEventListener('message', (event)=>{
4587
+ try {
4588
+ var _this_onmessage, _this;
4589
+ const data = JSON.parse(event.data);
4590
+ null === (_this_onmessage = (_this = this).onmessage) || void 0 === _this_onmessage || _this_onmessage.call(_this, data, event);
4591
+ } catch (error) {
4592
+ console.error('WebSocketAPI onmessage error', error);
4593
+ }
4594
+ });
4595
+ this.rws.addEventListener('open', (event)=>{
4596
+ var _this_onopen, _this;
4597
+ null === (_this_onopen = (_this = this).onopen) || void 0 === _this_onopen || _this_onopen.call(_this, event);
4598
+ });
4599
+ this.rws.addEventListener('close', (event)=>{
4600
+ var _this_onclose, _this;
4601
+ null === (_this_onclose = (_this = this).onclose) || void 0 === _this_onclose || _this_onclose.call(_this, event);
4602
+ });
4603
+ this.rws.addEventListener('error', (event)=>{
4604
+ var _event_target__req_res, _event_target__req, _event_target, _event_target__req_res1, _event_target__req1, _event_target1, _this_onerror, _this;
4605
+ const statusCode = null === (_event_target = event.target) || void 0 === _event_target ? void 0 : null === (_event_target__req = _event_target._req) || void 0 === _event_target__req ? void 0 : null === (_event_target__req_res = _event_target__req.res) || void 0 === _event_target__req_res ? void 0 : _event_target__req_res.statusCode;
4606
+ const rawHeaders = (null === (_event_target1 = event.target) || void 0 === _event_target1 ? void 0 : null === (_event_target__req1 = _event_target1._req) || void 0 === _event_target__req1 ? void 0 : null === (_event_target__req_res1 = _event_target__req1.res) || void 0 === _event_target__req_res1 ? void 0 : _event_target__req_res1.rawHeaders) || [];
4607
+ const logidIndex = rawHeaders.findIndex((header)=>'X-Tt-Logid' === header);
4608
+ const logid = -1 !== logidIndex ? rawHeaders[logidIndex + 1] : void 0;
4609
+ const error = {
4610
+ id: '0',
4611
+ event_type: types_WebsocketsEventType.ERROR,
4612
+ data: {
4613
+ code: -1,
4614
+ msg: 'WebSocket error'
4615
+ },
4616
+ detail: {
4617
+ logid
4618
+ }
4619
+ };
4620
+ if (401 === statusCode) {
4621
+ error.data.code = 401;
4622
+ error.data.msg = 'Unauthorized';
4623
+ } else if (403 === statusCode) {
4624
+ error.data.code = 403;
4625
+ error.data.msg = 'Forbidden';
4626
+ } else {
4627
+ error.data.code = 500;
4628
+ error.data.msg = String(null == event ? void 0 : event.error) || 'WebSocket error';
4629
+ }
4630
+ null === (_this_onerror = (_this = this).onerror) || void 0 === _this_onerror || _this_onerror.call(_this, error, event);
4631
+ });
4632
+ }
4633
+ }
3935
4634
  // EXTERNAL MODULE: os (ignored)
3936
4635
  var os_ignored_ = __webpack_require__("?9050");
3937
4636
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
3938
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","type":"module","exports":{".":"./src/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4637
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","type":"module","exports":{".":"./src/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
3939
4638
  const { version: version_version } = package_namespaceObject;
3940
4639
  const getEnv = ()=>{
3941
4640
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -4034,6 +4733,9 @@
4034
4733
  };
4035
4734
  return JSON.stringify(ua);
4036
4735
  };
4736
+ // EXTERNAL MODULE: node-fetch (ignored)
4737
+ var node_fetch_ignored_ = __webpack_require__("?8dee");
4738
+ var node_fetch_ignored_default = /*#__PURE__*/ __webpack_require__.n(node_fetch_ignored_);
4037
4739
  /* eslint-disable @typescript-eslint/no-explicit-any */ const fetcher_handleError = (error)=>{
4038
4740
  if (!error.isAxiosError && (!error.code || !error.message)) return new CozeError(`Unexpected error: ${error.message}`);
4039
4741
  if ('ECONNABORTED' === error.code && error.message.includes('timeout') || 'ETIMEDOUT' === error.code) {
@@ -4046,6 +4748,23 @@
4046
4748
  return error_APIError.generate((null === (_error_response1 = error.response) || void 0 === _error_response1 ? void 0 : _error_response1.status) || 500, null === (_error_response2 = error.response) || void 0 === _error_response2 ? void 0 : _error_response2.data, error.message, null === (_error_response3 = error.response) || void 0 === _error_response3 ? void 0 : _error_response3.headers);
4047
4749
  }
4048
4750
  };
4751
+ // node-fetch is used for streaming requests
4752
+ const adapterFetch = async (options)=>{
4753
+ const response = await node_fetch_ignored_default()(options.url, {
4754
+ body: options.data,
4755
+ ...options
4756
+ });
4757
+ return {
4758
+ data: response.body,
4759
+ ...response
4760
+ };
4761
+ };
4762
+ const isSupportNativeFetch = ()=>{
4763
+ if (utils_isBrowser()) return true;
4764
+ // native fetch is supported in node 18.0.0 or higher
4765
+ const version = process.version.slice(1);
4766
+ return compareVersions(version, '18.0.0') >= 0;
4767
+ };
4049
4768
  async function fetchAPI(url) {
4050
4769
  let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
4051
4770
  const axiosInstance = options.axiosInstance || lib_axios;
@@ -4057,7 +4776,7 @@
4057
4776
  const response = await axiosInstance({
4058
4777
  url,
4059
4778
  responseType: options.isStreaming ? 'stream' : 'json',
4060
- adapter: options.isStreaming ? 'fetch' : void 0,
4779
+ adapter: options.isStreaming ? isSupportNativeFetch() ? 'fetch' : adapterFetch : void 0,
4061
4780
  ...options
4062
4781
  }).catch((error)=>{
4063
4782
  throw fetcher_handleError(error);
@@ -4123,6 +4842,9 @@
4123
4842
  /**
4124
4843
  * default coze base URL is api.coze.com
4125
4844
  */ const constant_COZE_COM_BASE_URL = 'https://api.coze.com';
4845
+ /**
4846
+ * default base websocket URL is wss://ws.coze.com
4847
+ */ const COZE_COM_BASE_WS_URL = 'wss://ws.coze.com';
4126
4848
  /* eslint-disable max-params */ class core_APIClient {
4127
4849
  async getToken() {
4128
4850
  if ('function' == typeof this.token) return await this.token();
@@ -4147,6 +4869,26 @@
4147
4869
  config.data = body;
4148
4870
  return config;
4149
4871
  }
4872
+ async buildWebsocketOptions(options) {
4873
+ const token = await this.getToken();
4874
+ const headers = {
4875
+ authorization: `Bearer ${token}`
4876
+ };
4877
+ if (utils_isBrowser()) headers['X-Coze-Client-User-Agent'] = getBrowserClientUserAgent();
4878
+ else {
4879
+ headers['User-Agent'] = getUserAgent();
4880
+ headers['X-Coze-Client-User-Agent'] = getNodeClientUserAgent();
4881
+ }
4882
+ var _this__config_debug;
4883
+ const config = mergeConfig({
4884
+ debug: null !== (_this__config_debug = this._config.debug) && void 0 !== _this__config_debug && _this__config_debug
4885
+ }, this._config.websocketOptions, options, {
4886
+ headers
4887
+ }, {
4888
+ headers: this.headers || {}
4889
+ });
4890
+ return config;
4891
+ }
4150
4892
  async makeRequest(apiUrl, method, body, isStream, options) {
4151
4893
  const fullUrl = `${this.baseURL}${apiUrl}`;
4152
4894
  const fetchOptions = await this.buildOptions(method, body, options);
@@ -4194,6 +4936,14 @@
4194
4936
  async delete(apiUrl, isStream, options) {
4195
4937
  return this.makeRequest(apiUrl, 'DELETE', void 0, isStream, options);
4196
4938
  }
4939
+ async makeWebsocket(apiUrl, options) {
4940
+ const fullUrl = `${this.baseWsURL}${apiUrl}`;
4941
+ const websocketOptions = await this.buildWebsocketOptions(options);
4942
+ this.debugLog(null == options ? void 0 : options.debug, `--- websocket url: ${fullUrl}`);
4943
+ this.debugLog(null == options ? void 0 : options.debug, '--- websocket options:', websocketOptions);
4944
+ const ws = new WebSocketAPI(fullUrl, websocketOptions);
4945
+ return ws;
4946
+ }
4197
4947
  getConfig() {
4198
4948
  return this._config;
4199
4949
  }
@@ -4206,6 +4956,7 @@
4206
4956
  constructor(config){
4207
4957
  this._config = config;
4208
4958
  this.baseURL = config.baseURL || constant_COZE_COM_BASE_URL;
4959
+ this.baseWsURL = config.baseWsURL || COZE_COM_BASE_WS_URL;
4209
4960
  this.token = config.token;
4210
4961
  this.axiosOptions = config.axiosOptions || {};
4211
4962
  this.axiosInstance = config.axiosInstance;
@@ -4233,7 +4984,7 @@
4233
4984
  constructor(...args){
4234
4985
  super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this), /**
4235
4986
  * @deprecated
4236
- */ this.knowledge = new Knowledge(this), this.datasets = new Datasets(this), this.workflows = new Workflows(this), this.workspaces = new WorkSpaces(this), this.audio = new audio_Audio(this), this.templates = new Templates(this);
4987
+ */ this.knowledge = new Knowledge(this), this.datasets = new Datasets(this), this.workflows = new Workflows(this), this.workspaces = new WorkSpaces(this), this.audio = new audio_Audio(this), this.templates = new Templates(this), this.websockets = new Websockets(this);
4237
4988
  }
4238
4989
  }
4239
4990
  /**
@@ -42388,7 +43139,8 @@
42388
43139
  conversation_id: conversationId || void 0,
42389
43140
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
42390
43141
  connector_id: this._config.connectorId,
42391
- uid: this._config.userId || void 0
43142
+ uid: this._config.userId || void 0,
43143
+ workflow_id: this._config.workflowId || void 0
42392
43144
  });
42393
43145
  } catch (error) {
42394
43146
  this.dispatch(event_handler_EventNames.ERROR, error);