@volley/recognition-client-sdk 0.1.297 → 0.1.381

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.
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/zod@3.22.5/node_modules/zod/lib/index.mjs
1
+ // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
2
2
  var util;
3
3
  (function(util2) {
4
4
  util2.assertEqual = (val) => val;
@@ -3604,14 +3604,14 @@ var ostring = () => stringType().optional();
3604
3604
  var onumber = () => numberType().optional();
3605
3605
  var oboolean = () => booleanType().optional();
3606
3606
  var coerce = {
3607
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3608
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3609
- boolean: ((arg) => ZodBoolean.create({
3607
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3608
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3609
+ boolean: (arg) => ZodBoolean.create({
3610
3610
  ...arg,
3611
3611
  coerce: true
3612
- })),
3613
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3614
- date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
3612
+ }),
3613
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3614
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3615
3615
  };
3616
3616
  var NEVER = INVALID;
3617
3617
  var z = /* @__PURE__ */ Object.freeze({
@@ -3735,9 +3735,12 @@ var RecognitionProvider;
3735
3735
  (function(RecognitionProvider2) {
3736
3736
  RecognitionProvider2["ASSEMBLYAI"] = "assemblyai";
3737
3737
  RecognitionProvider2["DEEPGRAM"] = "deepgram";
3738
+ RecognitionProvider2["ELEVENLABS"] = "elevenlabs";
3739
+ RecognitionProvider2["FIREWORKS"] = "fireworks";
3738
3740
  RecognitionProvider2["GOOGLE"] = "google";
3739
3741
  RecognitionProvider2["GEMINI_BATCH"] = "gemini-batch";
3740
3742
  RecognitionProvider2["OPENAI_BATCH"] = "openai-batch";
3743
+ RecognitionProvider2["OPENAI_REALTIME"] = "openai-realtime";
3741
3744
  })(RecognitionProvider || (RecognitionProvider = {}));
3742
3745
  var RecognitionMode;
3743
3746
  (function(RecognitionMode2) {
@@ -3757,17 +3760,34 @@ var DeepgramModel;
3757
3760
  })(DeepgramModel || (DeepgramModel = {}));
3758
3761
  var GoogleModel;
3759
3762
  (function(GoogleModel2) {
3763
+ GoogleModel2["CHIRP_3"] = "chirp_3";
3764
+ GoogleModel2["CHIRP_2"] = "chirp_2";
3765
+ GoogleModel2["CHIRP"] = "chirp";
3760
3766
  GoogleModel2["LATEST_LONG"] = "latest_long";
3761
3767
  GoogleModel2["LATEST_SHORT"] = "latest_short";
3762
3768
  GoogleModel2["TELEPHONY"] = "telephony";
3763
3769
  GoogleModel2["TELEPHONY_SHORT"] = "telephony_short";
3764
- GoogleModel2["MEDICAL_DICTATION"] = "medical_dictation";
3765
- GoogleModel2["MEDICAL_CONVERSATION"] = "medical_conversation";
3766
3770
  GoogleModel2["DEFAULT"] = "default";
3767
3771
  GoogleModel2["COMMAND_AND_SEARCH"] = "command_and_search";
3768
3772
  GoogleModel2["PHONE_CALL"] = "phone_call";
3769
3773
  GoogleModel2["VIDEO"] = "video";
3770
3774
  })(GoogleModel || (GoogleModel = {}));
3775
+ var FireworksModel;
3776
+ (function(FireworksModel2) {
3777
+ FireworksModel2["ASR_V1"] = "fireworks-asr-large";
3778
+ FireworksModel2["ASR_V2"] = "fireworks-asr-v2";
3779
+ FireworksModel2["WHISPER_V3"] = "whisper-v3";
3780
+ FireworksModel2["WHISPER_V3_TURBO"] = "whisper-v3-turbo";
3781
+ })(FireworksModel || (FireworksModel = {}));
3782
+ var ElevenLabsModel;
3783
+ (function(ElevenLabsModel2) {
3784
+ ElevenLabsModel2["SCRIBE_V2_REALTIME"] = "scribe_v2_realtime";
3785
+ ElevenLabsModel2["SCRIBE_V1"] = "scribe_v1";
3786
+ })(ElevenLabsModel || (ElevenLabsModel = {}));
3787
+ var OpenAIRealtimeModel;
3788
+ (function(OpenAIRealtimeModel2) {
3789
+ OpenAIRealtimeModel2["GPT_4O_MINI_TRANSCRIBE"] = "gpt-4o-mini-transcribe";
3790
+ })(OpenAIRealtimeModel || (OpenAIRealtimeModel = {}));
3771
3791
 
3772
3792
  // ../../libs/types/dist/recognition-result-v1.types.js
3773
3793
  var RecognitionResultTypeV1;
@@ -3781,68 +3801,44 @@ var RecognitionResultTypeV1;
3781
3801
  var TranscriptionResultSchemaV1 = z.object({
3782
3802
  type: z.literal(RecognitionResultTypeV1.TRANSCRIPTION),
3783
3803
  audioUtteranceId: z.string(),
3784
- // audio utterance id for this transcription session
3785
3804
  finalTranscript: z.string(),
3786
- // transcript that is final and won't be overwritten by ASR. default empty string.
3787
3805
  finalTranscriptConfidence: z.number().min(0).max(1).optional(),
3788
- // confidence score for the final transcript (0-1). Optional.
3789
3806
  pendingTranscript: z.string().optional(),
3790
- // transcript that may be overwritten by ASR. Optional.
3791
3807
  pendingTranscriptConfidence: z.number().min(0).max(1).optional(),
3792
- // confidence score for the pending transcript (0-1). Optional.
3793
3808
  is_finished: z.boolean(),
3794
- // entire transcription finished. This will be the last message in the transcription.
3795
3809
  voiceStart: z.number().optional(),
3796
- // voice start time identified by ASR (in milliseconds from stream start). Optional.
3797
3810
  voiceDuration: z.number().optional(),
3798
- // voice duration identified by ASR (in milliseconds, calculated as maxVoiceEnd - voiceStart). Optional.
3799
3811
  voiceEnd: z.number().optional(),
3800
- // voice end time identified by ASR (in milliseconds from stream start). Optional.
3801
3812
  startTimestamp: z.number().optional(),
3802
- // start timestamp of the transcription in milliseconds. Optional.
3803
3813
  endTimestamp: z.number().optional(),
3804
- // end timestamp of the transcription in milliseconds. Optional.
3805
3814
  receivedAtMs: z.number().optional(),
3806
- // server timestamp when this transcript was received (ms since epoch). Optional.
3807
3815
  accumulatedAudioTimeMs: z.number().optional()
3808
3816
  // accumulated audio time watermark in milliseconds. Total duration of all audio chunks sent. Optional.
3809
3817
  });
3810
3818
  var FunctionCallResultSchemaV1 = z.object({
3811
3819
  type: z.literal(RecognitionResultTypeV1.FUNCTION_CALL),
3812
3820
  audioUtteranceId: z.string(),
3813
- // audio utterance id for this function call
3814
3821
  functionName: z.string(),
3815
3822
  functionArgJson: z.string()
3816
3823
  });
3817
3824
  var MetadataResultSchemaV1 = z.object({
3818
3825
  type: z.literal(RecognitionResultTypeV1.METADATA),
3819
3826
  audioUtteranceId: z.string(),
3820
- // audio utterance id for this metadata
3821
3827
  // Timing information
3822
3828
  recordingStartMs: z.number().optional(),
3823
- // When recording started
3824
3829
  recordingEndMs: z.number().optional(),
3825
- // When recording ended
3826
3830
  transcriptEndMs: z.number().optional(),
3827
- // When final transcript was received
3828
3831
  socketCloseAtMs: z.number().optional(),
3829
- // When socket/connection closed
3830
3832
  // Audio Quality Metrics
3831
3833
  duration: z.number().optional(),
3832
- // Duration of the audio in milliseconds
3833
3834
  volume: z.number().optional(),
3834
- // Volume of the audio in decibels
3835
3835
  accumulatedAudioTimeMs: z.number().optional(),
3836
- // Accumulated audio time watermark in milliseconds. Total duration of all audio chunks sent. Optional.
3837
3836
  // Cost Information
3838
3837
  costInUSD: z.number().default(0).optional(),
3839
- // Estimated cost in USD for this recognition session. Default: 0
3840
3838
  // ASR API Type
3841
3839
  apiType: z.nativeEnum(ASRApiType).optional(),
3842
- // ASR API type from job (streaming vs file-based)
3843
3840
  // ASR configuration as JSON string (no type validation)
3844
3841
  asrConfig: z.string().optional(),
3845
- // Stringified JSON of the ASR provider config
3846
3842
  // Raw ASR metadata payload as provided by the provider (stringified if needed)
3847
3843
  rawAsrMetadata: z.string().optional()
3848
3844
  });
@@ -3859,13 +3855,9 @@ var ErrorTypeV1;
3859
3855
  var ErrorResultSchemaV1 = z.object({
3860
3856
  type: z.literal(RecognitionResultTypeV1.ERROR),
3861
3857
  audioUtteranceId: z.string(),
3862
- // audio utterance id for this error
3863
3858
  errorType: z.nativeEnum(ErrorTypeV1).optional(),
3864
- // error type category
3865
3859
  message: z.string().optional(),
3866
- // Error message
3867
3860
  code: z.union([z.string(), z.number()]).optional(),
3868
- // Error code
3869
3861
  description: z.string().optional()
3870
3862
  // Detailed description
3871
3863
  });
@@ -3877,9 +3869,7 @@ var ClientControlActionV1;
3877
3869
  var ClientControlActionsV1 = z.nativeEnum(ClientControlActionV1);
3878
3870
  var ClientControlMessageSchemaV1 = z.object({
3879
3871
  type: z.literal(RecognitionResultTypeV1.CLIENT_CONTROL_MESSAGE),
3880
- // Message type discriminator
3881
3872
  audioUtteranceId: z.string(),
3882
- // audio utterance id for this control message
3883
3873
  action: ClientControlActionsV1
3884
3874
  // The control action to perform
3885
3875
  });
@@ -4017,7 +4007,6 @@ var MetadataMessageSchema = z.object({
4017
4007
  type: z.literal(ProviderMessageType.METADATA),
4018
4008
  provider: z.nativeEnum(RecognitionProvider),
4019
4009
  asrConfig: z.string().optional(),
4020
- // ASR config we sent to provider
4021
4010
  data: z.string().optional()
4022
4011
  // Raw metadata from provider (Deepgram only)
4023
4012
  });
@@ -4141,7 +4130,6 @@ var BaseRecognitionExceptionSchema = z.object({
4141
4130
  var AuthenticationExceptionSchema = BaseRecognitionExceptionSchema.extend({
4142
4131
  errorType: z.literal(ErrorTypeV1.AUTHENTICATION_ERROR),
4143
4132
  isImmediatelyAvailable: z.literal(false),
4144
- // System issue, not user-facing
4145
4133
  /** Which service failed authentication (e.g., 'deepgram', 'google') */
4146
4134
  service: z.string().optional(),
4147
4135
  /** Authentication method that failed (e.g., 'api_key', 'oauth') */
@@ -4150,7 +4138,6 @@ var AuthenticationExceptionSchema = BaseRecognitionExceptionSchema.extend({
4150
4138
  var ValidationExceptionSchema = BaseRecognitionExceptionSchema.extend({
4151
4139
  errorType: z.literal(ErrorTypeV1.VALIDATION_ERROR),
4152
4140
  isImmediatelyAvailable: z.literal(true),
4153
- // Can show to user
4154
4141
  /** Field name that failed validation */
4155
4142
  field: z.string().optional(),
4156
4143
  /** Expected value format/type */
@@ -4161,7 +4148,6 @@ var ValidationExceptionSchema = BaseRecognitionExceptionSchema.extend({
4161
4148
  var ProviderExceptionSchema = BaseRecognitionExceptionSchema.extend({
4162
4149
  errorType: z.literal(ErrorTypeV1.PROVIDER_ERROR),
4163
4150
  isImmediatelyAvailable: z.literal(false),
4164
- // Provider issue, not user-facing
4165
4151
  /** Provider name (e.g., 'deepgram', 'assemblyai', 'google') */
4166
4152
  provider: z.string().optional(),
4167
4153
  /** Provider-specific error code */
@@ -4172,7 +4158,6 @@ var ProviderExceptionSchema = BaseRecognitionExceptionSchema.extend({
4172
4158
  var TimeoutExceptionSchema = BaseRecognitionExceptionSchema.extend({
4173
4159
  errorType: z.literal(ErrorTypeV1.TIMEOUT_ERROR),
4174
4160
  isImmediatelyAvailable: z.literal(true),
4175
- // Can tell user to try again
4176
4161
  /** Timeout duration in milliseconds */
4177
4162
  timeoutMs: z.number().optional(),
4178
4163
  /** What operation timed out (e.g., 'connection', 'transcription', 'response') */
@@ -4181,7 +4166,6 @@ var TimeoutExceptionSchema = BaseRecognitionExceptionSchema.extend({
4181
4166
  var QuotaExceededExceptionSchema = BaseRecognitionExceptionSchema.extend({
4182
4167
  errorType: z.literal(ErrorTypeV1.QUOTA_EXCEEDED),
4183
4168
  isImmediatelyAvailable: z.literal(true),
4184
- // Can tell user to wait
4185
4169
  /** Quota type that was exceeded (e.g., 'rate_limit', 'daily_quota', 'concurrent_requests') */
4186
4170
  quotaType: z.string().optional(),
4187
4171
  /** When quota resets (Unix timestamp in ms) */
@@ -4192,7 +4176,6 @@ var QuotaExceededExceptionSchema = BaseRecognitionExceptionSchema.extend({
4192
4176
  var ConnectionExceptionSchema = BaseRecognitionExceptionSchema.extend({
4193
4177
  errorType: z.literal(ErrorTypeV1.CONNECTION_ERROR),
4194
4178
  isImmediatelyAvailable: z.literal(true),
4195
- // Can tell user about network issues
4196
4179
  /** Number of connection attempts made */
4197
4180
  attempts: z.number().optional(),
4198
4181
  /** URL that failed to connect */
@@ -4203,7 +4186,6 @@ var ConnectionExceptionSchema = BaseRecognitionExceptionSchema.extend({
4203
4186
  var UnknownExceptionSchema = BaseRecognitionExceptionSchema.extend({
4204
4187
  errorType: z.literal(ErrorTypeV1.UNKNOWN_ERROR),
4205
4188
  isImmediatelyAvailable: z.literal(false),
4206
- // Unknown cause, not user-facing
4207
4189
  /** Stack trace for debugging (sanitized) */
4208
4190
  stack: z.string().optional(),
4209
4191
  /** Additional context for debugging */
@@ -4235,16 +4217,11 @@ var SlotMapSchema = z.record(z.string(), z.array(z.string()));
4235
4217
  var GameContextSchemaV1 = z.object({
4236
4218
  type: z.literal(RecognitionContextTypeV1.GAME_CONTEXT),
4237
4219
  gameId: z.string(),
4238
- // Unique identifier for the game
4239
4220
  gamePhase: z.string(),
4240
- // Current phase of the game
4241
4221
  // Prompt fields for different processing stages
4242
4222
  promptSTT: z.string().optional(),
4243
- // Speech-to-Text: Keywords/phrases to optimize ASR (e.g., for Deepgram keywords)
4244
4223
  promptSTF: z.string().optional(),
4245
- // Speech-to-Function: Direct speech to function mapping instructions
4246
4224
  promptTTF: z.string().optional(),
4247
- // Text-to-Function: Text to function mapping instructions after transcription
4248
4225
  // Slot map for entity extraction
4249
4226
  slotMap: SlotMapSchema.optional()
4250
4227
  // Map of slot names to possible values to enhance prompting and keyword matching.
@@ -4271,7 +4248,6 @@ var ASRRequestSchemaV1 = z.object({
4271
4248
  type: z.literal(RecognitionContextTypeV1.ASR_REQUEST),
4272
4249
  // Session identification
4273
4250
  audioUtteranceId: z.string().optional(),
4274
- // Optional utterance ID (prefer query param)
4275
4251
  // ASR configuration
4276
4252
  provider: z.string(),
4277
4253
  model: z.string().optional(),
@@ -4280,12 +4256,9 @@ var ASRRequestSchemaV1 = z.object({
4280
4256
  encoding: z.number(),
4281
4257
  // Recognition options
4282
4258
  interimResults: z.boolean().optional().default(false),
4283
- // Enable interim/partial results
4284
4259
  useContext: z.boolean().optional().default(false),
4285
- // If true, requires GameContext before session creation
4286
4260
  // Final transcript stability mode (timeout for fallback final transcript)
4287
4261
  finalTranscriptStability: z.string().optional(),
4288
- // Stability mode: 'aggressive' | 'balanced' | 'conservative'
4289
4262
  // Debug options (FOR DEBUG/TESTING ONLY - not for production use)
4290
4263
  debugCommand: RequestDebugCommandSchema
4291
4264
  });
@@ -4298,31 +4271,22 @@ var RecognitionContextSchemaV1 = z.discriminatedUnion("type", [
4298
4271
  // ../../libs/types/dist/recognition-query.types.js
4299
4272
  var RecognitionGameInfoSchema = z.object({
4300
4273
  userId: z.string().optional(),
4301
- // User identifier
4302
4274
  gameSessionId: z.string().optional(),
4303
- // Volly session identifier . Called "sessionId" in Platform and most games.
4304
4275
  deviceId: z.string().optional(),
4305
- // Device identifier
4306
4276
  accountId: z.string().optional(),
4307
- // Account identifier
4308
4277
  gameId: z.string().optional(),
4309
- // Game identifier
4310
4278
  gamePhase: z.string().optional(),
4311
- // Game phase or scene. A string that describes the current state of the game for client team to optimize specific turn.
4312
4279
  questionAnswerId: z.string().optional(),
4313
- // Question answer identifier for tracking Q&A sessions
4314
4280
  platform: z.string().optional()
4315
4281
  // Platform for audio recording device (use the definition of platform teams)
4316
4282
  });
4317
4283
  var RecognitionQueryMetadataSchema = z.object({
4318
4284
  audioUtteranceId: z.string(),
4319
- // Audio utterance ID to query
4320
4285
  recognitionGameInfo: RecognitionGameInfoSchema.optional()
4321
4286
  // Optional game info for security
4322
4287
  });
4323
4288
  var UtteranceResourceResponseSchema = z.object({
4324
4289
  audioUtteranceId: z.string(),
4325
- // Audio utterance ID
4326
4290
  results: z.array(z.any())
4327
4291
  // Array of RecognitionResult (version-specific)
4328
4292
  });
@@ -4579,10 +4543,7 @@ var GeminiModel;
4579
4543
  GeminiModel2["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
4580
4544
  GeminiModel2["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
4581
4545
  GeminiModel2["GEMINI_2_0_FLASH_LATEST"] = "gemini-2.0-flash-latest";
4582
- GeminiModel2["GEMINI_2_0_FLASH"] = "gemini-2.0-flash-002";
4583
4546
  GeminiModel2["GEMINI_2_0_FLASH_EXP"] = "gemini-2.0-flash-exp";
4584
- GeminiModel2["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
4585
- GeminiModel2["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
4586
4547
  })(GeminiModel || (GeminiModel = {}));
4587
4548
  var GeminiApiVersion;
4588
4549
  (function(GeminiApiVersion2) {
@@ -4779,7 +4740,7 @@ var WebSocketAudioClient = class {
4779
4740
  // ../../libs/websocket/dist/core/audio-upload-websocket-server.js
4780
4741
  import { WebSocketServer, WebSocket as WebSocket2 } from "ws";
4781
4742
 
4782
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/stringify.js
4743
+ // ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/stringify.js
4783
4744
  var byteToHex = [];
4784
4745
  for (let i = 0; i < 256; ++i) {
4785
4746
  byteToHex.push((i + 256).toString(16).slice(1));
@@ -4788,7 +4749,7 @@ function unsafeStringify(arr, offset = 0) {
4788
4749
  return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
4789
4750
  }
4790
4751
 
4791
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/rng.js
4752
+ // ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/rng.js
4792
4753
  var getRandomValues;
4793
4754
  var rnds8 = new Uint8Array(16);
4794
4755
  function rng() {
@@ -4801,27 +4762,21 @@ function rng() {
4801
4762
  return getRandomValues(rnds8);
4802
4763
  }
4803
4764
 
4804
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/native.js
4765
+ // ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/native.js
4805
4766
  var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
4806
4767
  var native_default = { randomUUID };
4807
4768
 
4808
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js
4769
+ // ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/v4.js
4809
4770
  function v4(options, buf, offset) {
4810
4771
  if (native_default.randomUUID && !buf && !options) {
4811
4772
  return native_default.randomUUID();
4812
4773
  }
4813
4774
  options = options || {};
4814
- const rnds = options.random ?? options.rng?.() ?? rng();
4815
- if (rnds.length < 16) {
4816
- throw new Error("Random bytes length must be >= 16");
4817
- }
4775
+ const rnds = options.random || (options.rng || rng)();
4818
4776
  rnds[6] = rnds[6] & 15 | 64;
4819
4777
  rnds[8] = rnds[8] & 63 | 128;
4820
4778
  if (buf) {
4821
4779
  offset = offset || 0;
4822
- if (offset < 0 || offset + 16 > buf.length) {
4823
- throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
4824
- }
4825
4780
  for (let i = 0; i < 16; ++i) {
4826
4781
  buf[offset + i] = rnds[i];
4827
4782
  }
@@ -5546,16 +5501,65 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
5546
5501
  this.config.onConnected();
5547
5502
  }
5548
5503
  onDisconnected(code, reason) {
5549
- this.log("debug", "WebSocket disconnected", { code, reason, previousState: this.state });
5504
+ const closeCodeDescription = this.getCloseCodeDescription(code);
5505
+ const is1006 = code === 1006;
5506
+ this.log("debug", "[DIAGNOSTIC] WebSocket disconnected", {
5507
+ code,
5508
+ codeDescription: closeCodeDescription,
5509
+ reason: reason || "(empty)",
5510
+ previousState: this.state,
5511
+ is1006Abnormal: is1006,
5512
+ audioChunksSent: this.audioChunksSent,
5513
+ audioBytesSent: this.audioBytesSent,
5514
+ bufferStats: this.audioBuffer.getStats()
5515
+ });
5550
5516
  if (this.state === "stopping" /* STOPPING */) {
5551
5517
  this.state = "stopped" /* STOPPED */;
5552
5518
  } else if (this.state === "connected" /* CONNECTED */ || this.state === "ready" /* READY */ || this.state === "connecting" /* CONNECTING */) {
5553
- this.log("error", "Unexpected disconnection", { code, reason });
5519
+ this.log("error", "[DIAGNOSTIC] Unexpected disconnection", {
5520
+ code,
5521
+ codeDescription: closeCodeDescription,
5522
+ reason: reason || "(empty)",
5523
+ is1006,
5524
+ possibleCauses: is1006 ? [
5525
+ "Network connection lost",
5526
+ "Server process crashed",
5527
+ "Provider (Deepgram/AssemblyAI) WebSocket closed abnormally",
5528
+ "Firewall/proxy terminated connection",
5529
+ "Browser/tab suspended (mobile)"
5530
+ ] : []
5531
+ });
5554
5532
  this.state = "failed" /* FAILED */;
5555
5533
  }
5556
5534
  this.cleanup();
5557
5535
  this.config.onDisconnected(code, reason);
5558
5536
  }
5537
+ /**
5538
+ * Get human-readable description for WebSocket close code
5539
+ */
5540
+ getCloseCodeDescription(code) {
5541
+ const descriptions = {
5542
+ 1e3: "Normal Closure",
5543
+ 1001: "Going Away",
5544
+ 1002: "Protocol Error",
5545
+ 1003: "Unsupported Data",
5546
+ 1005: "No Status Received",
5547
+ 1006: "Abnormal Closure (no close frame received)",
5548
+ 1007: "Invalid Frame Payload",
5549
+ 1008: "Policy Violation",
5550
+ 1009: "Message Too Big",
5551
+ 1010: "Mandatory Extension",
5552
+ 1011: "Internal Server Error",
5553
+ 1012: "Service Restart",
5554
+ 1013: "Try Again Later",
5555
+ 4e3: "Auth Required",
5556
+ 4001: "Auth Failed",
5557
+ 4002: "Rate Limit Exceeded",
5558
+ 4003: "Invalid Session",
5559
+ 4004: "Session Expired"
5560
+ };
5561
+ return descriptions[code] || `Unknown (${code})`;
5562
+ }
5559
5563
  onError(error) {
5560
5564
  this.state = "failed" /* FAILED */;
5561
5565
  const errorResult = {