@layercode/js-sdk 2.1.3 → 2.1.4

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.
@@ -795,6 +795,8 @@ class AudioProcessor extends AudioWorkletProcessor {
795
795
  constructor() {
796
796
  super();
797
797
  this.port.onmessage = this.receive.bind(this);
798
+ this.downsampleRatio = 1;
799
+ this.downsampleOffset = 0;
798
800
  this.initialize();
799
801
  }
800
802
 
@@ -802,7 +804,6 @@ class AudioProcessor extends AudioWorkletProcessor {
802
804
  this.foundAudio = false;
803
805
  this.recording = false;
804
806
  this.chunks = [];
805
- this.downsampleRatio = 1;
806
807
  this.downsampleOffset = 0;
807
808
  }
808
809
 
@@ -4011,22 +4012,14 @@ class LayercodeClient {
4011
4012
  this.stopRecorderAmplitude = undefined;
4012
4013
  }
4013
4014
  /**
4014
- * Connects to the Layercode agent and starts the audio conversation
4015
+ * Connects to the Layercode agent using the stored conversation ID and starts the audio conversation
4015
4016
  * @async
4016
4017
  * @returns {Promise<void>}
4017
4018
  */
4018
- async connect(opts) {
4019
+ async connect() {
4019
4020
  if (this.status === 'connecting') {
4020
4021
  return;
4021
4022
  }
4022
- if (opts === null || opts === void 0 ? void 0 : opts.newConversation) {
4023
- this.options.conversationId = null;
4024
- this.conversationId = null;
4025
- }
4026
- else if (opts === null || opts === void 0 ? void 0 : opts.conversationId) {
4027
- this.options.conversationId = opts.conversationId;
4028
- this.conversationId = opts.conversationId;
4029
- }
4030
4023
  try {
4031
4024
  this._setStatus('connecting');
4032
4025
  // Reset turn tracking for clean start
@@ -4115,7 +4108,7 @@ class LayercodeClient {
4115
4108
  this.currentTurnId = null;
4116
4109
  console.debug('Reset turn tracking state');
4117
4110
  }
4118
- async disconnect(opts) {
4111
+ async disconnect() {
4119
4112
  if (this.status === 'disconnected') {
4120
4113
  return;
4121
4114
  }
@@ -4127,7 +4120,7 @@ class LayercodeClient {
4127
4120
  this.ws.close();
4128
4121
  this.ws = null;
4129
4122
  }
4130
- await this._performDisconnectCleanup(opts === null || opts === void 0 ? void 0 : opts.clearConversationId);
4123
+ await this._performDisconnectCleanup();
4131
4124
  }
4132
4125
  /**
4133
4126
  * Gets the microphone MediaStream used by this client
@@ -4274,7 +4267,10 @@ class LayercodeClient {
4274
4267
  _teardownDeviceListeners() {
4275
4268
  this.wavRecorder.listenForDeviceChange(null);
4276
4269
  }
4277
- async _performDisconnectCleanup(clearConversationId) {
4270
+ /**
4271
+ * Releases audio resources and listeners after a disconnect
4272
+ */
4273
+ async _performDisconnectCleanup() {
4278
4274
  var _a, _b;
4279
4275
  this.deviceId = null;
4280
4276
  this.activeDeviceId = null;
@@ -4294,13 +4290,7 @@ class LayercodeClient {
4294
4290
  (_b = (_a = this.wavPlayer).stop) === null || _b === void 0 ? void 0 : _b.call(_a);
4295
4291
  this.wavPlayer.disconnect();
4296
4292
  this._resetTurnTracking();
4297
- if (clearConversationId) {
4298
- this.options.conversationId = null;
4299
- this.conversationId = null;
4300
- }
4301
- else {
4302
- this.options.conversationId = this.conversationId;
4303
- }
4293
+ this.options.conversationId = this.conversationId;
4304
4294
  this.userAudioAmplitude = 0;
4305
4295
  this.agentAudioAmplitude = 0;
4306
4296
  this._setStatus('disconnected');