@volley/recognition-client-sdk 0.1.210 → 0.1.254

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/index.d.ts CHANGED
@@ -1,7 +1,573 @@
1
- import { A as ASRRequestConfig, G as GameContextV1, R as RecognitionCallbackUrl, T as TranscriptionResultV1, M as MetadataResultV1, E as ErrorResultV1, a as RealTimeTwoWayWebSocketRecognitionClientConfig, I as IRecognitionClient, C as ClientState, b as IRecognitionClientConfig } from './browser-C4ZssGoU.js';
2
- export { k as ASRRequestV1, f as AudioEncoding, h as ControlSignal, h as ControlSignalTypeV1, D as DeepgramModel, F as FunctionCallResultV1, m as GoogleModel, e as IRecognitionClientStats, L as Language, c as RealTimeTwoWayWebSocketRecognitionClient, g as RecognitionContextTypeV1, l as RecognitionProvider, j as RecognitionResultTypeV1, S as SampleRate, d as TranscriptionResult, i as isNormalDisconnection } from './browser-C4ZssGoU.js';
1
+ import { R as RecognitionProvider, E as ErrorTypeV1, S as Stage, A as ASRRequestConfig, G as GameContextV1, a as RecognitionCallbackUrl, T as TranscriptionResultV1, M as MetadataResultV1, b as ErrorResultV1, c as RealTimeTwoWayWebSocketRecognitionClientConfig, I as IRecognitionClient, C as ClientState, d as IRecognitionClientConfig } from './browser-BZs4BL_w.js';
2
+ export { m as ASRRequestV1, h as AudioEncoding, k as ControlSignal, k as ControlSignalTypeV1, D as DeepgramModel, F as FunctionCallResultV1, n as GoogleModel, g as IRecognitionClientStats, L as Language, e as RealTimeTwoWayWebSocketRecognitionClient, j as RecognitionContextTypeV1, l as RecognitionResultTypeV1, p as STAGES, o as SampleRate, f as TranscriptionResult, i as isNormalDisconnection } from './browser-BZs4BL_w.js';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Error Exception Types
7
+ *
8
+ * Defines structured exception types for each ErrorTypeV1 category.
9
+ * Each exception type has metadata about whether it's immediately available
10
+ * (can be shown to user right away vs needs investigation/retry).
11
+ */
12
+
13
+ /**
14
+ * Authentication/Authorization Error
15
+ * isImmediatelyAvailable: false
16
+ * These are system configuration issues, not user-facing
17
+ */
18
+ declare const AuthenticationExceptionSchema: z.ZodObject<{
19
+ message: z.ZodString;
20
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
21
+ description: z.ZodOptional<z.ZodString>;
22
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
23
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
24
+ timestamp: z.ZodOptional<z.ZodNumber>;
25
+ } & {
26
+ errorType: z.ZodLiteral<ErrorTypeV1.AUTHENTICATION_ERROR>;
27
+ isImmediatelyAvailable: z.ZodLiteral<false>;
28
+ service: z.ZodOptional<z.ZodString>;
29
+ authMethod: z.ZodOptional<z.ZodString>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ message: string;
32
+ errorType: ErrorTypeV1.AUTHENTICATION_ERROR;
33
+ isImmediatelyAvailable: false;
34
+ provider?: RecognitionProvider | undefined;
35
+ code?: string | number | undefined;
36
+ audioUtteranceId?: string | undefined;
37
+ description?: string | undefined;
38
+ timestamp?: number | undefined;
39
+ service?: string | undefined;
40
+ authMethod?: string | undefined;
41
+ }, {
42
+ message: string;
43
+ errorType: ErrorTypeV1.AUTHENTICATION_ERROR;
44
+ isImmediatelyAvailable: false;
45
+ provider?: RecognitionProvider | undefined;
46
+ code?: string | number | undefined;
47
+ audioUtteranceId?: string | undefined;
48
+ description?: string | undefined;
49
+ timestamp?: number | undefined;
50
+ service?: string | undefined;
51
+ authMethod?: string | undefined;
52
+ }>;
53
+ type AuthenticationException = z.infer<typeof AuthenticationExceptionSchema>;
54
+ /**
55
+ * Validation Error
56
+ * isImmediatelyAvailable: true
57
+ * User provided invalid input - can show them what's wrong
58
+ */
59
+ declare const ValidationExceptionSchema: z.ZodObject<{
60
+ message: z.ZodString;
61
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
62
+ description: z.ZodOptional<z.ZodString>;
63
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
64
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
65
+ timestamp: z.ZodOptional<z.ZodNumber>;
66
+ } & {
67
+ errorType: z.ZodLiteral<ErrorTypeV1.VALIDATION_ERROR>;
68
+ isImmediatelyAvailable: z.ZodLiteral<true>;
69
+ field: z.ZodOptional<z.ZodString>;
70
+ expected: z.ZodOptional<z.ZodString>;
71
+ received: z.ZodOptional<z.ZodString>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ message: string;
74
+ errorType: ErrorTypeV1.VALIDATION_ERROR;
75
+ isImmediatelyAvailable: true;
76
+ provider?: RecognitionProvider | undefined;
77
+ code?: string | number | undefined;
78
+ expected?: string | undefined;
79
+ received?: string | undefined;
80
+ audioUtteranceId?: string | undefined;
81
+ description?: string | undefined;
82
+ timestamp?: number | undefined;
83
+ field?: string | undefined;
84
+ }, {
85
+ message: string;
86
+ errorType: ErrorTypeV1.VALIDATION_ERROR;
87
+ isImmediatelyAvailable: true;
88
+ provider?: RecognitionProvider | undefined;
89
+ code?: string | number | undefined;
90
+ expected?: string | undefined;
91
+ received?: string | undefined;
92
+ audioUtteranceId?: string | undefined;
93
+ description?: string | undefined;
94
+ timestamp?: number | undefined;
95
+ field?: string | undefined;
96
+ }>;
97
+ type ValidationException = z.infer<typeof ValidationExceptionSchema>;
98
+ /**
99
+ * Provider Error
100
+ * isImmediatelyAvailable: false
101
+ * Error from ASR provider - usually transient or needs investigation
102
+ */
103
+ declare const ProviderExceptionSchema: z.ZodObject<{
104
+ message: z.ZodString;
105
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
106
+ description: z.ZodOptional<z.ZodString>;
107
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
108
+ timestamp: z.ZodOptional<z.ZodNumber>;
109
+ } & {
110
+ errorType: z.ZodLiteral<ErrorTypeV1.PROVIDER_ERROR>;
111
+ isImmediatelyAvailable: z.ZodLiteral<false>;
112
+ provider: z.ZodOptional<z.ZodString>;
113
+ providerErrorCode: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
114
+ isTransient: z.ZodOptional<z.ZodBoolean>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ message: string;
117
+ errorType: ErrorTypeV1.PROVIDER_ERROR;
118
+ isImmediatelyAvailable: false;
119
+ provider?: string | undefined;
120
+ code?: string | number | undefined;
121
+ audioUtteranceId?: string | undefined;
122
+ description?: string | undefined;
123
+ timestamp?: number | undefined;
124
+ providerErrorCode?: string | number | undefined;
125
+ isTransient?: boolean | undefined;
126
+ }, {
127
+ message: string;
128
+ errorType: ErrorTypeV1.PROVIDER_ERROR;
129
+ isImmediatelyAvailable: false;
130
+ provider?: string | undefined;
131
+ code?: string | number | undefined;
132
+ audioUtteranceId?: string | undefined;
133
+ description?: string | undefined;
134
+ timestamp?: number | undefined;
135
+ providerErrorCode?: string | number | undefined;
136
+ isTransient?: boolean | undefined;
137
+ }>;
138
+ type ProviderException = z.infer<typeof ProviderExceptionSchema>;
139
+ /**
140
+ * Timeout Error
141
+ * isImmediatelyAvailable: true
142
+ * Request took too long - user should try again
143
+ */
144
+ declare const TimeoutExceptionSchema: z.ZodObject<{
145
+ message: z.ZodString;
146
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
147
+ description: z.ZodOptional<z.ZodString>;
148
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
149
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
150
+ timestamp: z.ZodOptional<z.ZodNumber>;
151
+ } & {
152
+ errorType: z.ZodLiteral<ErrorTypeV1.TIMEOUT_ERROR>;
153
+ isImmediatelyAvailable: z.ZodLiteral<true>;
154
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
155
+ operation: z.ZodOptional<z.ZodString>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ message: string;
158
+ errorType: ErrorTypeV1.TIMEOUT_ERROR;
159
+ isImmediatelyAvailable: true;
160
+ provider?: RecognitionProvider | undefined;
161
+ code?: string | number | undefined;
162
+ audioUtteranceId?: string | undefined;
163
+ description?: string | undefined;
164
+ timestamp?: number | undefined;
165
+ timeoutMs?: number | undefined;
166
+ operation?: string | undefined;
167
+ }, {
168
+ message: string;
169
+ errorType: ErrorTypeV1.TIMEOUT_ERROR;
170
+ isImmediatelyAvailable: true;
171
+ provider?: RecognitionProvider | undefined;
172
+ code?: string | number | undefined;
173
+ audioUtteranceId?: string | undefined;
174
+ description?: string | undefined;
175
+ timestamp?: number | undefined;
176
+ timeoutMs?: number | undefined;
177
+ operation?: string | undefined;
178
+ }>;
179
+ type TimeoutException = z.infer<typeof TimeoutExceptionSchema>;
180
+ /**
181
+ * Quota Exceeded Error
182
+ * isImmediatelyAvailable: true
183
+ * Rate limit or quota exceeded - user should wait
184
+ */
185
+ declare const QuotaExceededExceptionSchema: z.ZodObject<{
186
+ message: z.ZodString;
187
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
188
+ description: z.ZodOptional<z.ZodString>;
189
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
190
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
191
+ timestamp: z.ZodOptional<z.ZodNumber>;
192
+ } & {
193
+ errorType: z.ZodLiteral<ErrorTypeV1.QUOTA_EXCEEDED>;
194
+ isImmediatelyAvailable: z.ZodLiteral<true>;
195
+ quotaType: z.ZodOptional<z.ZodString>;
196
+ resetAt: z.ZodOptional<z.ZodNumber>;
197
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
198
+ }, "strip", z.ZodTypeAny, {
199
+ message: string;
200
+ errorType: ErrorTypeV1.QUOTA_EXCEEDED;
201
+ isImmediatelyAvailable: true;
202
+ provider?: RecognitionProvider | undefined;
203
+ code?: string | number | undefined;
204
+ audioUtteranceId?: string | undefined;
205
+ description?: string | undefined;
206
+ timestamp?: number | undefined;
207
+ quotaType?: string | undefined;
208
+ resetAt?: number | undefined;
209
+ retryAfterSeconds?: number | undefined;
210
+ }, {
211
+ message: string;
212
+ errorType: ErrorTypeV1.QUOTA_EXCEEDED;
213
+ isImmediatelyAvailable: true;
214
+ provider?: RecognitionProvider | undefined;
215
+ code?: string | number | undefined;
216
+ audioUtteranceId?: string | undefined;
217
+ description?: string | undefined;
218
+ timestamp?: number | undefined;
219
+ quotaType?: string | undefined;
220
+ resetAt?: number | undefined;
221
+ retryAfterSeconds?: number | undefined;
222
+ }>;
223
+ type QuotaExceededException = z.infer<typeof QuotaExceededExceptionSchema>;
224
+ /**
225
+ * Connection Error
226
+ * isImmediatelyAvailable: true
227
+ * Connection establishment or network failure - user should check network or retry
228
+ */
229
+ declare const ConnectionExceptionSchema: z.ZodObject<{
230
+ message: z.ZodString;
231
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
232
+ description: z.ZodOptional<z.ZodString>;
233
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
234
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
235
+ timestamp: z.ZodOptional<z.ZodNumber>;
236
+ } & {
237
+ errorType: z.ZodLiteral<ErrorTypeV1.CONNECTION_ERROR>;
238
+ isImmediatelyAvailable: z.ZodLiteral<true>;
239
+ attempts: z.ZodOptional<z.ZodNumber>;
240
+ url: z.ZodOptional<z.ZodString>;
241
+ underlyingError: z.ZodOptional<z.ZodString>;
242
+ }, "strip", z.ZodTypeAny, {
243
+ message: string;
244
+ errorType: ErrorTypeV1.CONNECTION_ERROR;
245
+ isImmediatelyAvailable: true;
246
+ provider?: RecognitionProvider | undefined;
247
+ code?: string | number | undefined;
248
+ audioUtteranceId?: string | undefined;
249
+ description?: string | undefined;
250
+ timestamp?: number | undefined;
251
+ attempts?: number | undefined;
252
+ url?: string | undefined;
253
+ underlyingError?: string | undefined;
254
+ }, {
255
+ message: string;
256
+ errorType: ErrorTypeV1.CONNECTION_ERROR;
257
+ isImmediatelyAvailable: true;
258
+ provider?: RecognitionProvider | undefined;
259
+ code?: string | number | undefined;
260
+ audioUtteranceId?: string | undefined;
261
+ description?: string | undefined;
262
+ timestamp?: number | undefined;
263
+ attempts?: number | undefined;
264
+ url?: string | undefined;
265
+ underlyingError?: string | undefined;
266
+ }>;
267
+ type ConnectionException = z.infer<typeof ConnectionExceptionSchema>;
268
+ /**
269
+ * Unknown Error
270
+ * isImmediatelyAvailable: false
271
+ * Unexpected error - needs investigation
272
+ */
273
+ declare const UnknownExceptionSchema: z.ZodObject<{
274
+ message: z.ZodString;
275
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
276
+ description: z.ZodOptional<z.ZodString>;
277
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
278
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
279
+ timestamp: z.ZodOptional<z.ZodNumber>;
280
+ } & {
281
+ errorType: z.ZodLiteral<ErrorTypeV1.UNKNOWN_ERROR>;
282
+ isImmediatelyAvailable: z.ZodLiteral<false>;
283
+ stack: z.ZodOptional<z.ZodString>;
284
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
285
+ }, "strip", z.ZodTypeAny, {
286
+ message: string;
287
+ errorType: ErrorTypeV1.UNKNOWN_ERROR;
288
+ isImmediatelyAvailable: false;
289
+ provider?: RecognitionProvider | undefined;
290
+ code?: string | number | undefined;
291
+ audioUtteranceId?: string | undefined;
292
+ description?: string | undefined;
293
+ timestamp?: number | undefined;
294
+ stack?: string | undefined;
295
+ context?: Record<string, unknown> | undefined;
296
+ }, {
297
+ message: string;
298
+ errorType: ErrorTypeV1.UNKNOWN_ERROR;
299
+ isImmediatelyAvailable: false;
300
+ provider?: RecognitionProvider | undefined;
301
+ code?: string | number | undefined;
302
+ audioUtteranceId?: string | undefined;
303
+ description?: string | undefined;
304
+ timestamp?: number | undefined;
305
+ stack?: string | undefined;
306
+ context?: Record<string, unknown> | undefined;
307
+ }>;
308
+ type UnknownException = z.infer<typeof UnknownExceptionSchema>;
309
+ /**
310
+ * Discriminated union of all exception types
311
+ * Use this for type-safe error handling
312
+ */
313
+ declare const RecognitionExceptionSchema: z.ZodDiscriminatedUnion<"errorType", [z.ZodObject<{
314
+ message: z.ZodString;
315
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
316
+ description: z.ZodOptional<z.ZodString>;
317
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
318
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
319
+ timestamp: z.ZodOptional<z.ZodNumber>;
320
+ } & {
321
+ errorType: z.ZodLiteral<ErrorTypeV1.AUTHENTICATION_ERROR>;
322
+ isImmediatelyAvailable: z.ZodLiteral<false>;
323
+ service: z.ZodOptional<z.ZodString>;
324
+ authMethod: z.ZodOptional<z.ZodString>;
325
+ }, "strip", z.ZodTypeAny, {
326
+ message: string;
327
+ errorType: ErrorTypeV1.AUTHENTICATION_ERROR;
328
+ isImmediatelyAvailable: false;
329
+ provider?: RecognitionProvider | undefined;
330
+ code?: string | number | undefined;
331
+ audioUtteranceId?: string | undefined;
332
+ description?: string | undefined;
333
+ timestamp?: number | undefined;
334
+ service?: string | undefined;
335
+ authMethod?: string | undefined;
336
+ }, {
337
+ message: string;
338
+ errorType: ErrorTypeV1.AUTHENTICATION_ERROR;
339
+ isImmediatelyAvailable: false;
340
+ provider?: RecognitionProvider | undefined;
341
+ code?: string | number | undefined;
342
+ audioUtteranceId?: string | undefined;
343
+ description?: string | undefined;
344
+ timestamp?: number | undefined;
345
+ service?: string | undefined;
346
+ authMethod?: string | undefined;
347
+ }>, z.ZodObject<{
348
+ message: z.ZodString;
349
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
350
+ description: z.ZodOptional<z.ZodString>;
351
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
352
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
353
+ timestamp: z.ZodOptional<z.ZodNumber>;
354
+ } & {
355
+ errorType: z.ZodLiteral<ErrorTypeV1.VALIDATION_ERROR>;
356
+ isImmediatelyAvailable: z.ZodLiteral<true>;
357
+ field: z.ZodOptional<z.ZodString>;
358
+ expected: z.ZodOptional<z.ZodString>;
359
+ received: z.ZodOptional<z.ZodString>;
360
+ }, "strip", z.ZodTypeAny, {
361
+ message: string;
362
+ errorType: ErrorTypeV1.VALIDATION_ERROR;
363
+ isImmediatelyAvailable: true;
364
+ provider?: RecognitionProvider | undefined;
365
+ code?: string | number | undefined;
366
+ expected?: string | undefined;
367
+ received?: string | undefined;
368
+ audioUtteranceId?: string | undefined;
369
+ description?: string | undefined;
370
+ timestamp?: number | undefined;
371
+ field?: string | undefined;
372
+ }, {
373
+ message: string;
374
+ errorType: ErrorTypeV1.VALIDATION_ERROR;
375
+ isImmediatelyAvailable: true;
376
+ provider?: RecognitionProvider | undefined;
377
+ code?: string | number | undefined;
378
+ expected?: string | undefined;
379
+ received?: string | undefined;
380
+ audioUtteranceId?: string | undefined;
381
+ description?: string | undefined;
382
+ timestamp?: number | undefined;
383
+ field?: string | undefined;
384
+ }>, z.ZodObject<{
385
+ message: z.ZodString;
386
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
387
+ description: z.ZodOptional<z.ZodString>;
388
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
389
+ timestamp: z.ZodOptional<z.ZodNumber>;
390
+ } & {
391
+ errorType: z.ZodLiteral<ErrorTypeV1.PROVIDER_ERROR>;
392
+ isImmediatelyAvailable: z.ZodLiteral<false>;
393
+ provider: z.ZodOptional<z.ZodString>;
394
+ providerErrorCode: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
395
+ isTransient: z.ZodOptional<z.ZodBoolean>;
396
+ }, "strip", z.ZodTypeAny, {
397
+ message: string;
398
+ errorType: ErrorTypeV1.PROVIDER_ERROR;
399
+ isImmediatelyAvailable: false;
400
+ provider?: string | undefined;
401
+ code?: string | number | undefined;
402
+ audioUtteranceId?: string | undefined;
403
+ description?: string | undefined;
404
+ timestamp?: number | undefined;
405
+ providerErrorCode?: string | number | undefined;
406
+ isTransient?: boolean | undefined;
407
+ }, {
408
+ message: string;
409
+ errorType: ErrorTypeV1.PROVIDER_ERROR;
410
+ isImmediatelyAvailable: false;
411
+ provider?: string | undefined;
412
+ code?: string | number | undefined;
413
+ audioUtteranceId?: string | undefined;
414
+ description?: string | undefined;
415
+ timestamp?: number | undefined;
416
+ providerErrorCode?: string | number | undefined;
417
+ isTransient?: boolean | undefined;
418
+ }>, z.ZodObject<{
419
+ message: z.ZodString;
420
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
421
+ description: z.ZodOptional<z.ZodString>;
422
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
423
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
424
+ timestamp: z.ZodOptional<z.ZodNumber>;
425
+ } & {
426
+ errorType: z.ZodLiteral<ErrorTypeV1.TIMEOUT_ERROR>;
427
+ isImmediatelyAvailable: z.ZodLiteral<true>;
428
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
429
+ operation: z.ZodOptional<z.ZodString>;
430
+ }, "strip", z.ZodTypeAny, {
431
+ message: string;
432
+ errorType: ErrorTypeV1.TIMEOUT_ERROR;
433
+ isImmediatelyAvailable: true;
434
+ provider?: RecognitionProvider | undefined;
435
+ code?: string | number | undefined;
436
+ audioUtteranceId?: string | undefined;
437
+ description?: string | undefined;
438
+ timestamp?: number | undefined;
439
+ timeoutMs?: number | undefined;
440
+ operation?: string | undefined;
441
+ }, {
442
+ message: string;
443
+ errorType: ErrorTypeV1.TIMEOUT_ERROR;
444
+ isImmediatelyAvailable: true;
445
+ provider?: RecognitionProvider | undefined;
446
+ code?: string | number | undefined;
447
+ audioUtteranceId?: string | undefined;
448
+ description?: string | undefined;
449
+ timestamp?: number | undefined;
450
+ timeoutMs?: number | undefined;
451
+ operation?: string | undefined;
452
+ }>, z.ZodObject<{
453
+ message: z.ZodString;
454
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
455
+ description: z.ZodOptional<z.ZodString>;
456
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
457
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
458
+ timestamp: z.ZodOptional<z.ZodNumber>;
459
+ } & {
460
+ errorType: z.ZodLiteral<ErrorTypeV1.QUOTA_EXCEEDED>;
461
+ isImmediatelyAvailable: z.ZodLiteral<true>;
462
+ quotaType: z.ZodOptional<z.ZodString>;
463
+ resetAt: z.ZodOptional<z.ZodNumber>;
464
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
465
+ }, "strip", z.ZodTypeAny, {
466
+ message: string;
467
+ errorType: ErrorTypeV1.QUOTA_EXCEEDED;
468
+ isImmediatelyAvailable: true;
469
+ provider?: RecognitionProvider | undefined;
470
+ code?: string | number | undefined;
471
+ audioUtteranceId?: string | undefined;
472
+ description?: string | undefined;
473
+ timestamp?: number | undefined;
474
+ quotaType?: string | undefined;
475
+ resetAt?: number | undefined;
476
+ retryAfterSeconds?: number | undefined;
477
+ }, {
478
+ message: string;
479
+ errorType: ErrorTypeV1.QUOTA_EXCEEDED;
480
+ isImmediatelyAvailable: true;
481
+ provider?: RecognitionProvider | undefined;
482
+ code?: string | number | undefined;
483
+ audioUtteranceId?: string | undefined;
484
+ description?: string | undefined;
485
+ timestamp?: number | undefined;
486
+ quotaType?: string | undefined;
487
+ resetAt?: number | undefined;
488
+ retryAfterSeconds?: number | undefined;
489
+ }>, z.ZodObject<{
490
+ message: z.ZodString;
491
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
492
+ description: z.ZodOptional<z.ZodString>;
493
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
494
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
495
+ timestamp: z.ZodOptional<z.ZodNumber>;
496
+ } & {
497
+ errorType: z.ZodLiteral<ErrorTypeV1.CONNECTION_ERROR>;
498
+ isImmediatelyAvailable: z.ZodLiteral<true>;
499
+ attempts: z.ZodOptional<z.ZodNumber>;
500
+ url: z.ZodOptional<z.ZodString>;
501
+ underlyingError: z.ZodOptional<z.ZodString>;
502
+ }, "strip", z.ZodTypeAny, {
503
+ message: string;
504
+ errorType: ErrorTypeV1.CONNECTION_ERROR;
505
+ isImmediatelyAvailable: true;
506
+ provider?: RecognitionProvider | undefined;
507
+ code?: string | number | undefined;
508
+ audioUtteranceId?: string | undefined;
509
+ description?: string | undefined;
510
+ timestamp?: number | undefined;
511
+ attempts?: number | undefined;
512
+ url?: string | undefined;
513
+ underlyingError?: string | undefined;
514
+ }, {
515
+ message: string;
516
+ errorType: ErrorTypeV1.CONNECTION_ERROR;
517
+ isImmediatelyAvailable: true;
518
+ provider?: RecognitionProvider | undefined;
519
+ code?: string | number | undefined;
520
+ audioUtteranceId?: string | undefined;
521
+ description?: string | undefined;
522
+ timestamp?: number | undefined;
523
+ attempts?: number | undefined;
524
+ url?: string | undefined;
525
+ underlyingError?: string | undefined;
526
+ }>, z.ZodObject<{
527
+ message: z.ZodString;
528
+ code: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
529
+ description: z.ZodOptional<z.ZodString>;
530
+ provider: z.ZodOptional<z.ZodNativeEnum<typeof RecognitionProvider>>;
531
+ audioUtteranceId: z.ZodOptional<z.ZodString>;
532
+ timestamp: z.ZodOptional<z.ZodNumber>;
533
+ } & {
534
+ errorType: z.ZodLiteral<ErrorTypeV1.UNKNOWN_ERROR>;
535
+ isImmediatelyAvailable: z.ZodLiteral<false>;
536
+ stack: z.ZodOptional<z.ZodString>;
537
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
538
+ }, "strip", z.ZodTypeAny, {
539
+ message: string;
540
+ errorType: ErrorTypeV1.UNKNOWN_ERROR;
541
+ isImmediatelyAvailable: false;
542
+ provider?: RecognitionProvider | undefined;
543
+ code?: string | number | undefined;
544
+ audioUtteranceId?: string | undefined;
545
+ description?: string | undefined;
546
+ timestamp?: number | undefined;
547
+ stack?: string | undefined;
548
+ context?: Record<string, unknown> | undefined;
549
+ }, {
550
+ message: string;
551
+ errorType: ErrorTypeV1.UNKNOWN_ERROR;
552
+ isImmediatelyAvailable: false;
553
+ provider?: RecognitionProvider | undefined;
554
+ code?: string | number | undefined;
555
+ audioUtteranceId?: string | undefined;
556
+ description?: string | undefined;
557
+ timestamp?: number | undefined;
558
+ stack?: string | undefined;
559
+ context?: Record<string, unknown> | undefined;
560
+ }>]>;
561
+ type RecognitionException = z.infer<typeof RecognitionExceptionSchema>;
562
+ /**
563
+ * Check if an exception should be shown to the user immediately
564
+ */
565
+ declare function isExceptionImmediatelyAvailable(exception: RecognitionException): boolean;
566
+ /**
567
+ * Get user-friendly error message for exceptions
568
+ */
569
+ declare function getUserFriendlyMessage(exception: RecognitionException): string;
570
+
5
571
  /**
6
572
  * Gemini Model Types
7
573
  * Based on available models as of January 2025
@@ -32,17 +598,6 @@ declare enum OpenAIModel {
32
598
  WHISPER_1 = "whisper-1"
33
599
  }
34
600
 
35
- /**
36
- * Standard stage/environment constants used across all services
37
- */
38
- declare const STAGES: {
39
- readonly LOCAL: "local";
40
- readonly DEV: "dev";
41
- readonly STAGING: "staging";
42
- readonly PRODUCTION: "production";
43
- };
44
- type Stage = typeof STAGES[keyof typeof STAGES];
45
-
46
601
  /**
47
602
  * Configuration Builder for Recognition Client
48
603
  *
@@ -56,8 +611,10 @@ type Stage = typeof STAGES[keyof typeof STAGES];
56
611
  *
57
612
  * Example:
58
613
  * ```typescript
614
+ * import { STAGES } from '@recog/shared-types';
615
+ *
59
616
  * const config = new ConfigBuilder()
60
- * .url('ws://localhost:3101/ws/v1/recognize')
617
+ * .stage(STAGES.STAGING) // Recommended: automatic environment selection
61
618
  * .asrRequestConfig({
62
619
  * provider: RecognitionProvider.DEEPGRAM,
63
620
  * model: 'nova-2-general'
@@ -69,9 +626,20 @@ type Stage = typeof STAGES[keyof typeof STAGES];
69
626
  declare class ConfigBuilder {
70
627
  private config;
71
628
  /**
72
- * Set the WebSocket URL
629
+ * Set the WebSocket URL (advanced usage)
630
+ * For standard environments, use stage() instead
73
631
  */
74
632
  url(url: string): this;
633
+ /**
634
+ * Set the stage for automatic environment selection (recommended)
635
+ * @param stage - STAGES.LOCAL | STAGES.DEV | STAGES.STAGING | STAGES.PRODUCTION
636
+ * @example
637
+ * ```typescript
638
+ * import { STAGES } from '@recog/shared-types';
639
+ * builder.stage(STAGES.STAGING)
640
+ * ```
641
+ */
642
+ stage(stage: Stage | string): this;
75
643
  /**
76
644
  * Set ASR request configuration
77
645
  */
@@ -193,6 +761,47 @@ declare function createClient(config: RealTimeTwoWayWebSocketRecognitionClientCo
193
761
  */
194
762
  declare function createClientWithBuilder(configure: (builder: ConfigBuilder) => ConfigBuilder): IRecognitionClient;
195
763
 
764
+ /**
765
+ * SDK Error Classes
766
+ *
767
+ * Typed error classes that extend native Error with recognition-specific metadata
768
+ */
769
+
770
+ /**
771
+ * Base class for all recognition SDK errors
772
+ */
773
+ declare class RecognitionError extends Error {
774
+ readonly errorType: ErrorTypeV1;
775
+ readonly timestamp: number;
776
+ constructor(errorType: ErrorTypeV1, message: string);
777
+ }
778
+ /**
779
+ * Connection error - thrown when WebSocket connection fails after all retry attempts
780
+ */
781
+ declare class ConnectionError extends RecognitionError {
782
+ readonly attempts: number;
783
+ readonly url: string;
784
+ readonly underlyingError?: Error;
785
+ constructor(message: string, attempts: number, url: string, underlyingError?: Error);
786
+ }
787
+ /**
788
+ * Timeout error - thrown when operations exceed timeout limits
789
+ */
790
+ declare class TimeoutError extends RecognitionError {
791
+ readonly timeoutMs: number;
792
+ readonly operation: string;
793
+ constructor(message: string, timeoutMs: number, operation: string);
794
+ }
795
+ /**
796
+ * Validation error - thrown when invalid configuration or input is provided
797
+ */
798
+ declare class ValidationError extends RecognitionError {
799
+ readonly field?: string;
800
+ readonly expected?: string;
801
+ readonly received?: string;
802
+ constructor(message: string, field?: string, expected?: string, received?: string);
803
+ }
804
+
196
805
  /**
197
806
  * VGF-style state schema for game-side recognition state/results management.
198
807
  *
@@ -349,6 +958,10 @@ interface ISimplifiedVGFRecognitionClient {
349
958
  * Get the audio utterance ID for this session
350
959
  */
351
960
  getAudioUtteranceId(): string;
961
+ /**
962
+ * Get the WebSocket URL being used
963
+ */
964
+ getUrl(): string;
352
965
  /**
353
966
  * Get the underlying client state (for advanced usage)
354
967
  */
@@ -368,6 +981,7 @@ declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognitio
368
981
  sendAudio(audioData: ArrayBuffer | ArrayBufferView | Blob): void;
369
982
  stopRecording(): Promise<void>;
370
983
  getAudioUtteranceId(): string;
984
+ getUrl(): string;
371
985
  getState(): ClientState;
372
986
  isConnected(): boolean;
373
987
  isConnecting(): boolean;
@@ -462,4 +1076,4 @@ declare function getRecognitionConductorHttpBase(stage?: Stage | string | null |
462
1076
  declare function getRecognitionConductorWsBase(stage?: Stage | string | null | undefined): string;
463
1077
  declare function getRecognitionConductorHost(stage?: Stage | string | null | undefined): string;
464
1078
 
465
- export { ASRRequestConfig, ClientState, ConfigBuilder, ErrorResultV1, GameContextV1, GeminiModel, IRecognitionClient, IRecognitionClientConfig, type ISimplifiedVGFRecognitionClient, MetadataResultV1, OpenAIModel, RECOGNITION_CONDUCTOR_BASES, RECOGNITION_SERVICE_BASES, RealTimeTwoWayWebSocketRecognitionClientConfig, RecognitionCallbackUrl, type RecognitionState, RecognitionVGFStateSchema, RecordingStatus, type RecordingStatusType, type SimplifiedVGFClientConfig, SimplifiedVGFRecognitionClient, TranscriptionResultV1, TranscriptionStatus, type TranscriptionStatusType, createClient, createClientWithBuilder, createInitialRecognitionState, createSimplifiedVGFClient, getRecognitionConductorBase, getRecognitionConductorHost, getRecognitionConductorHttpBase, getRecognitionConductorWsBase, getRecognitionServiceBase, getRecognitionServiceHost, getRecognitionServiceHttpBase, getRecognitionServiceWsBase, isValidRecordingStatusTransition, normalizeStage };
1079
+ export { ASRRequestConfig, type AuthenticationException, ClientState, ConfigBuilder, ConnectionError, type ConnectionException, ErrorResultV1, ErrorTypeV1, GameContextV1, GeminiModel, IRecognitionClient, IRecognitionClientConfig, type ISimplifiedVGFRecognitionClient, MetadataResultV1, OpenAIModel, type ProviderException, type QuotaExceededException, RECOGNITION_CONDUCTOR_BASES, RECOGNITION_SERVICE_BASES, RealTimeTwoWayWebSocketRecognitionClientConfig, RecognitionCallbackUrl, RecognitionError, type RecognitionException, RecognitionProvider, type RecognitionState, RecognitionVGFStateSchema, RecordingStatus, type RecordingStatusType, type SimplifiedVGFClientConfig, SimplifiedVGFRecognitionClient, Stage, TimeoutError, type TimeoutException, TranscriptionResultV1, TranscriptionStatus, type TranscriptionStatusType, type UnknownException, ValidationError, type ValidationException, createClient, createClientWithBuilder, createInitialRecognitionState, createSimplifiedVGFClient, getRecognitionConductorBase, getRecognitionConductorHost, getRecognitionConductorHttpBase, getRecognitionConductorWsBase, getRecognitionServiceBase, getRecognitionServiceHost, getRecognitionServiceHttpBase, getRecognitionServiceWsBase, getUserFriendlyMessage, isExceptionImmediatelyAvailable, isValidRecordingStatusTransition, normalizeStage };