@volley/recognition-client-sdk 0.1.255 → 0.1.287
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/browser.d.ts +10 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/config-builder.d.ts +129 -0
- package/dist/config-builder.d.ts.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/factory.d.ts +36 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.d.ts +15 -1079
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9760 -2109
- package/dist/index.js.map +7 -1
- package/dist/recog-client-sdk.browser.d.ts +10 -2
- package/dist/recog-client-sdk.browser.d.ts.map +1 -0
- package/dist/recog-client-sdk.browser.js +4597 -701
- package/dist/recog-client-sdk.browser.js.map +7 -1
- package/dist/recognition-client.d.ts +119 -0
- package/dist/recognition-client.d.ts.map +1 -0
- package/dist/recognition-client.types.d.ts +247 -0
- package/dist/recognition-client.types.d.ts.map +1 -0
- package/dist/simplified-vgf-recognition-client.d.ts +155 -0
- package/dist/simplified-vgf-recognition-client.d.ts.map +1 -0
- package/dist/utils/audio-ring-buffer.d.ts +69 -0
- package/dist/utils/audio-ring-buffer.d.ts.map +1 -0
- package/dist/utils/message-handler.d.ts +45 -0
- package/dist/utils/message-handler.d.ts.map +1 -0
- package/dist/utils/url-builder.d.ts +26 -0
- package/dist/utils/url-builder.d.ts.map +1 -0
- package/dist/vgf-recognition-mapper.d.ts +53 -0
- package/dist/vgf-recognition-mapper.d.ts.map +1 -0
- package/dist/vgf-recognition-state.d.ts +81 -0
- package/dist/vgf-recognition-state.d.ts.map +1 -0
- package/package.json +7 -8
- package/src/index.ts +4 -0
- package/src/recognition-client.spec.ts +19 -14
- package/src/recognition-client.ts +4 -0
- package/src/utils/url-builder.spec.ts +5 -3
- package/dist/browser-BZs4BL_w.d.ts +0 -1118
package/dist/index.d.ts
CHANGED
|
@@ -1,1079 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Gemini Model Types
|
|
573
|
-
* Based on available models as of January 2025
|
|
574
|
-
*
|
|
575
|
-
* API Version Notes:
|
|
576
|
-
* - Gemini 2.5+ models: Use v1beta API (early access features)
|
|
577
|
-
* - Gemini 2.0 models: Use v1beta API (early access features)
|
|
578
|
-
* - Gemini 1.5 models: Use v1 API (stable, production-ready)
|
|
579
|
-
*
|
|
580
|
-
* @see https://ai.google.dev/gemini-api/docs/models
|
|
581
|
-
* @see https://ai.google.dev/gemini-api/docs/api-versions
|
|
582
|
-
*/
|
|
583
|
-
declare enum GeminiModel {
|
|
584
|
-
GEMINI_2_5_PRO = "gemini-2.5-pro",// State-of-the-art thinking model
|
|
585
|
-
GEMINI_2_5_FLASH = "gemini-2.5-flash",// Best price-performance balance
|
|
586
|
-
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",// Fastest, most cost-efficient
|
|
587
|
-
GEMINI_2_0_FLASH_LATEST = "gemini-2.0-flash-latest",// Auto-updated to latest 2.0 flash
|
|
588
|
-
GEMINI_2_0_FLASH = "gemini-2.0-flash-002",// Specific stable version
|
|
589
|
-
GEMINI_2_0_FLASH_EXP = "gemini-2.0-flash-exp",// Experimental version
|
|
590
|
-
GEMINI_1_5_FLASH = "gemini-1.5-flash",
|
|
591
|
-
GEMINI_1_5_PRO = "gemini-1.5-pro"
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* OpenAI Model Types
|
|
596
|
-
*/
|
|
597
|
-
declare enum OpenAIModel {
|
|
598
|
-
WHISPER_1 = "whisper-1"
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Configuration Builder for Recognition Client
|
|
603
|
-
*
|
|
604
|
-
* Simple builder pattern for RealTimeTwoWayWebSocketRecognitionClientConfig
|
|
605
|
-
*/
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Builder for RealTimeTwoWayWebSocketRecognitionClientConfig
|
|
609
|
-
*
|
|
610
|
-
* Provides a fluent API for building client configurations.
|
|
611
|
-
*
|
|
612
|
-
* Example:
|
|
613
|
-
* ```typescript
|
|
614
|
-
* import { STAGES } from '@recog/shared-types';
|
|
615
|
-
*
|
|
616
|
-
* const config = new ConfigBuilder()
|
|
617
|
-
* .stage(STAGES.STAGING) // Recommended: automatic environment selection
|
|
618
|
-
* .asrRequestConfig({
|
|
619
|
-
* provider: RecognitionProvider.DEEPGRAM,
|
|
620
|
-
* model: 'nova-2-general'
|
|
621
|
-
* })
|
|
622
|
-
* .onTranscript((result) => console.log(result))
|
|
623
|
-
* .build();
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
declare class ConfigBuilder {
|
|
627
|
-
private config;
|
|
628
|
-
/**
|
|
629
|
-
* Set the WebSocket URL (advanced usage)
|
|
630
|
-
* For standard environments, use stage() instead
|
|
631
|
-
*/
|
|
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;
|
|
643
|
-
/**
|
|
644
|
-
* Set ASR request configuration
|
|
645
|
-
*/
|
|
646
|
-
asrRequestConfig(config: ASRRequestConfig): this;
|
|
647
|
-
/**
|
|
648
|
-
* Set game context
|
|
649
|
-
*/
|
|
650
|
-
gameContext(context: GameContextV1): this;
|
|
651
|
-
/**
|
|
652
|
-
* Set audio utterance ID
|
|
653
|
-
*/
|
|
654
|
-
audioUtteranceId(id: string): this;
|
|
655
|
-
/**
|
|
656
|
-
* Set callback URLs
|
|
657
|
-
*/
|
|
658
|
-
callbackUrls(urls: RecognitionCallbackUrl[]): this;
|
|
659
|
-
/**
|
|
660
|
-
* Set user ID
|
|
661
|
-
*/
|
|
662
|
-
userId(id: string): this;
|
|
663
|
-
/**
|
|
664
|
-
* Set game session ID
|
|
665
|
-
*/
|
|
666
|
-
gameSessionId(id: string): this;
|
|
667
|
-
/**
|
|
668
|
-
* Set device ID
|
|
669
|
-
*/
|
|
670
|
-
deviceId(id: string): this;
|
|
671
|
-
/**
|
|
672
|
-
* Set account ID
|
|
673
|
-
*/
|
|
674
|
-
accountId(id: string): this;
|
|
675
|
-
/**
|
|
676
|
-
* Set question answer ID
|
|
677
|
-
*/
|
|
678
|
-
questionAnswerId(id: string): this;
|
|
679
|
-
/**
|
|
680
|
-
* Set platform
|
|
681
|
-
*/
|
|
682
|
-
platform(platform: string): this;
|
|
683
|
-
/**
|
|
684
|
-
* Set transcript callback
|
|
685
|
-
*/
|
|
686
|
-
onTranscript(callback: (result: TranscriptionResultV1) => void): this;
|
|
687
|
-
/**
|
|
688
|
-
* Set metadata callback
|
|
689
|
-
*/
|
|
690
|
-
onMetadata(callback: (metadata: MetadataResultV1) => void): this;
|
|
691
|
-
/**
|
|
692
|
-
* Set error callback
|
|
693
|
-
*/
|
|
694
|
-
onError(callback: (error: ErrorResultV1) => void): this;
|
|
695
|
-
/**
|
|
696
|
-
* Set connected callback
|
|
697
|
-
*/
|
|
698
|
-
onConnected(callback: () => void): this;
|
|
699
|
-
/**
|
|
700
|
-
* Set disconnected callback
|
|
701
|
-
*/
|
|
702
|
-
onDisconnected(callback: (code: number, reason: string) => void): this;
|
|
703
|
-
/**
|
|
704
|
-
* Set high water mark
|
|
705
|
-
*/
|
|
706
|
-
highWaterMark(bytes: number): this;
|
|
707
|
-
/**
|
|
708
|
-
* Set low water mark
|
|
709
|
-
*/
|
|
710
|
-
lowWaterMark(bytes: number): this;
|
|
711
|
-
/**
|
|
712
|
-
* Set max buffer duration in seconds
|
|
713
|
-
*/
|
|
714
|
-
maxBufferDurationSec(seconds: number): this;
|
|
715
|
-
/**
|
|
716
|
-
* Set chunks per second
|
|
717
|
-
*/
|
|
718
|
-
chunksPerSecond(chunks: number): this;
|
|
719
|
-
/**
|
|
720
|
-
* Set logger function
|
|
721
|
-
*/
|
|
722
|
-
logger(logger: (level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: any) => void): this;
|
|
723
|
-
/**
|
|
724
|
-
* Build the configuration
|
|
725
|
-
*/
|
|
726
|
-
build(): RealTimeTwoWayWebSocketRecognitionClientConfig;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Factory function for creating Recognition Client instances
|
|
731
|
-
*/
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* Create a recognition client from a configuration object
|
|
735
|
-
*
|
|
736
|
-
* Example:
|
|
737
|
-
* ```typescript
|
|
738
|
-
* const client = createClient({
|
|
739
|
-
* url: 'ws://localhost:3101/ws/v1/recognize',
|
|
740
|
-
* audioUtteranceId: 'unique-id',
|
|
741
|
-
* onTranscript: (result) => console.log(result)
|
|
742
|
-
* });
|
|
743
|
-
* ```
|
|
744
|
-
*
|
|
745
|
-
* @param config - Client configuration
|
|
746
|
-
* @returns Configured recognition client instance
|
|
747
|
-
*/
|
|
748
|
-
declare function createClient(config: RealTimeTwoWayWebSocketRecognitionClientConfig): IRecognitionClient;
|
|
749
|
-
/**
|
|
750
|
-
* Create a recognition client using the builder pattern
|
|
751
|
-
*
|
|
752
|
-
* Example:
|
|
753
|
-
* ```typescript
|
|
754
|
-
* const client = createClientWithBuilder((builder) =>
|
|
755
|
-
* builder
|
|
756
|
-
* .url('ws://localhost:3101/ws/v1/recognize')
|
|
757
|
-
* .onTranscript((result) => console.log(result))
|
|
758
|
-
* .onError((error) => console.error(error))
|
|
759
|
-
* );
|
|
760
|
-
* ```
|
|
761
|
-
*/
|
|
762
|
-
declare function createClientWithBuilder(configure: (builder: ConfigBuilder) => ConfigBuilder): IRecognitionClient;
|
|
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
|
-
|
|
805
|
-
/**
|
|
806
|
-
* VGF-style state schema for game-side recognition state/results management.
|
|
807
|
-
*
|
|
808
|
-
* This schema provides a standardized way for game developers to manage
|
|
809
|
-
* voice recognition state and results in their applications. It supports:
|
|
810
|
-
*
|
|
811
|
-
* STEP 1: Basic transcription flow
|
|
812
|
-
* STEP 2: Mic auto-stop upon correct answer (using partial transcripts)
|
|
813
|
-
* STEP 3: Semantic/function-call outcomes for game actions
|
|
814
|
-
*
|
|
815
|
-
* Ideally this should be part of a more centralized shared type library to free
|
|
816
|
-
* game developers and provide helper functions (VGF? Platform SDK?).
|
|
817
|
-
*/
|
|
818
|
-
declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
819
|
-
audioUtteranceId: z.ZodString;
|
|
820
|
-
startRecordingStatus: z.ZodOptional<z.ZodString>;
|
|
821
|
-
transcriptionStatus: z.ZodOptional<z.ZodString>;
|
|
822
|
-
finalTranscript: z.ZodOptional<z.ZodString>;
|
|
823
|
-
finalConfidence: z.ZodOptional<z.ZodNumber>;
|
|
824
|
-
asrConfig: z.ZodOptional<z.ZodString>;
|
|
825
|
-
startRecordingTimestamp: z.ZodOptional<z.ZodString>;
|
|
826
|
-
finalRecordingTimestamp: z.ZodOptional<z.ZodString>;
|
|
827
|
-
finalTranscriptionTimestamp: z.ZodOptional<z.ZodString>;
|
|
828
|
-
pendingTranscript: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
829
|
-
pendingConfidence: z.ZodOptional<z.ZodNumber>;
|
|
830
|
-
functionCallMetadata: z.ZodOptional<z.ZodString>;
|
|
831
|
-
functionCallConfidence: z.ZodOptional<z.ZodNumber>;
|
|
832
|
-
finalFunctionCallTimestamp: z.ZodOptional<z.ZodString>;
|
|
833
|
-
promptSlotMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
834
|
-
}, "strip", z.ZodTypeAny, {
|
|
835
|
-
audioUtteranceId: string;
|
|
836
|
-
pendingTranscript: string;
|
|
837
|
-
startRecordingStatus?: string | undefined;
|
|
838
|
-
transcriptionStatus?: string | undefined;
|
|
839
|
-
finalTranscript?: string | undefined;
|
|
840
|
-
finalConfidence?: number | undefined;
|
|
841
|
-
asrConfig?: string | undefined;
|
|
842
|
-
startRecordingTimestamp?: string | undefined;
|
|
843
|
-
finalRecordingTimestamp?: string | undefined;
|
|
844
|
-
finalTranscriptionTimestamp?: string | undefined;
|
|
845
|
-
pendingConfidence?: number | undefined;
|
|
846
|
-
functionCallMetadata?: string | undefined;
|
|
847
|
-
functionCallConfidence?: number | undefined;
|
|
848
|
-
finalFunctionCallTimestamp?: string | undefined;
|
|
849
|
-
promptSlotMap?: Record<string, string[]> | undefined;
|
|
850
|
-
}, {
|
|
851
|
-
audioUtteranceId: string;
|
|
852
|
-
startRecordingStatus?: string | undefined;
|
|
853
|
-
transcriptionStatus?: string | undefined;
|
|
854
|
-
finalTranscript?: string | undefined;
|
|
855
|
-
finalConfidence?: number | undefined;
|
|
856
|
-
asrConfig?: string | undefined;
|
|
857
|
-
startRecordingTimestamp?: string | undefined;
|
|
858
|
-
finalRecordingTimestamp?: string | undefined;
|
|
859
|
-
finalTranscriptionTimestamp?: string | undefined;
|
|
860
|
-
pendingTranscript?: string | undefined;
|
|
861
|
-
pendingConfidence?: number | undefined;
|
|
862
|
-
functionCallMetadata?: string | undefined;
|
|
863
|
-
functionCallConfidence?: number | undefined;
|
|
864
|
-
finalFunctionCallTimestamp?: string | undefined;
|
|
865
|
-
promptSlotMap?: Record<string, string[]> | undefined;
|
|
866
|
-
}>;
|
|
867
|
-
type RecognitionState = z.infer<typeof RecognitionVGFStateSchema>;
|
|
868
|
-
declare const RecordingStatus: {
|
|
869
|
-
readonly NOT_READY: "NOT_READY";
|
|
870
|
-
readonly READY: "READY";
|
|
871
|
-
readonly RECORDING: "RECORDING";
|
|
872
|
-
readonly FINISHED: "FINISHED";
|
|
873
|
-
};
|
|
874
|
-
type RecordingStatusType = typeof RecordingStatus[keyof typeof RecordingStatus];
|
|
875
|
-
declare const TranscriptionStatus: {
|
|
876
|
-
readonly NOT_STARTED: "NOT_STARTED";
|
|
877
|
-
readonly IN_PROGRESS: "IN_PROGRESS";
|
|
878
|
-
readonly FINALIZED: "FINALIZED";
|
|
879
|
-
readonly ERROR: "ERROR";
|
|
880
|
-
};
|
|
881
|
-
type TranscriptionStatusType = typeof TranscriptionStatus[keyof typeof TranscriptionStatus];
|
|
882
|
-
declare function createInitialRecognitionState(audioUtteranceId: string): RecognitionState;
|
|
883
|
-
declare function isValidRecordingStatusTransition(from: string | undefined, to: string): boolean;
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* Simplified VGF Recognition Client
|
|
887
|
-
*
|
|
888
|
-
* A thin wrapper around RealTimeTwoWayWebSocketRecognitionClient that maintains
|
|
889
|
-
* a VGF RecognitionState as a pure sink/output of recognition events.
|
|
890
|
-
*
|
|
891
|
-
* The VGF state is updated based on events but never influences client behavior.
|
|
892
|
-
* All functionality is delegated to the underlying client.
|
|
893
|
-
*/
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* Configuration for SimplifiedVGFRecognitionClient
|
|
897
|
-
*/
|
|
898
|
-
interface SimplifiedVGFClientConfig extends IRecognitionClientConfig {
|
|
899
|
-
/**
|
|
900
|
-
* Callback invoked whenever the VGF state changes
|
|
901
|
-
* Use this to update your UI or React state
|
|
902
|
-
*/
|
|
903
|
-
onStateChange?: (state: RecognitionState) => void;
|
|
904
|
-
/**
|
|
905
|
-
* Optional initial state to restore from a previous session
|
|
906
|
-
* If provided, audioUtteranceId will be extracted and used
|
|
907
|
-
*/
|
|
908
|
-
initialState?: RecognitionState;
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* Interface for SimplifiedVGFRecognitionClient
|
|
912
|
-
*
|
|
913
|
-
* A simplified client that maintains VGF state for game developers.
|
|
914
|
-
* All methods from the underlying client are available, plus VGF state management.
|
|
915
|
-
*/
|
|
916
|
-
interface ISimplifiedVGFRecognitionClient {
|
|
917
|
-
/**
|
|
918
|
-
* Connect to the recognition service WebSocket
|
|
919
|
-
* @returns Promise that resolves when connected and ready
|
|
920
|
-
*/
|
|
921
|
-
connect(): Promise<void>;
|
|
922
|
-
/**
|
|
923
|
-
* Send audio data for transcription
|
|
924
|
-
* @param audioData - PCM audio data as ArrayBuffer, typed array, or Blob
|
|
925
|
-
*/
|
|
926
|
-
sendAudio(audioData: ArrayBuffer | ArrayBufferView | Blob): void;
|
|
927
|
-
/**
|
|
928
|
-
* Stop recording and wait for final transcription
|
|
929
|
-
* @returns Promise that resolves when transcription is complete
|
|
930
|
-
*/
|
|
931
|
-
stopRecording(): Promise<void>;
|
|
932
|
-
/**
|
|
933
|
-
* Get the current VGF recognition state
|
|
934
|
-
* @returns Current RecognitionState with all transcription data
|
|
935
|
-
*/
|
|
936
|
-
getVGFState(): RecognitionState;
|
|
937
|
-
/**
|
|
938
|
-
* Check if connected to the WebSocket
|
|
939
|
-
*/
|
|
940
|
-
isConnected(): boolean;
|
|
941
|
-
/**
|
|
942
|
-
* Check if currently connecting
|
|
943
|
-
*/
|
|
944
|
-
isConnecting(): boolean;
|
|
945
|
-
/**
|
|
946
|
-
* Check if currently stopping
|
|
947
|
-
*/
|
|
948
|
-
isStopping(): boolean;
|
|
949
|
-
/**
|
|
950
|
-
* Check if transcription has finished
|
|
951
|
-
*/
|
|
952
|
-
isTranscriptionFinished(): boolean;
|
|
953
|
-
/**
|
|
954
|
-
* Check if the audio buffer has overflowed
|
|
955
|
-
*/
|
|
956
|
-
isBufferOverflowing(): boolean;
|
|
957
|
-
/**
|
|
958
|
-
* Get the audio utterance ID for this session
|
|
959
|
-
*/
|
|
960
|
-
getAudioUtteranceId(): string;
|
|
961
|
-
/**
|
|
962
|
-
* Get the WebSocket URL being used
|
|
963
|
-
*/
|
|
964
|
-
getUrl(): string;
|
|
965
|
-
/**
|
|
966
|
-
* Get the underlying client state (for advanced usage)
|
|
967
|
-
*/
|
|
968
|
-
getState(): ClientState;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* This wrapper ONLY maintains VGF state as a sink.
|
|
972
|
-
* All actual functionality is delegated to the underlying client.
|
|
973
|
-
*/
|
|
974
|
-
declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognitionClient {
|
|
975
|
-
private client;
|
|
976
|
-
private state;
|
|
977
|
-
private isRecordingAudio;
|
|
978
|
-
private stateChangeCallback;
|
|
979
|
-
constructor(config: SimplifiedVGFClientConfig);
|
|
980
|
-
connect(): Promise<void>;
|
|
981
|
-
sendAudio(audioData: ArrayBuffer | ArrayBufferView | Blob): void;
|
|
982
|
-
stopRecording(): Promise<void>;
|
|
983
|
-
getAudioUtteranceId(): string;
|
|
984
|
-
getUrl(): string;
|
|
985
|
-
getState(): ClientState;
|
|
986
|
-
isConnected(): boolean;
|
|
987
|
-
isConnecting(): boolean;
|
|
988
|
-
isStopping(): boolean;
|
|
989
|
-
isTranscriptionFinished(): boolean;
|
|
990
|
-
isBufferOverflowing(): boolean;
|
|
991
|
-
getVGFState(): RecognitionState;
|
|
992
|
-
private notifyStateChange;
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* Factory function for creating simplified client
|
|
996
|
-
* Usage examples:
|
|
997
|
-
*
|
|
998
|
-
* // Basic usage
|
|
999
|
-
* const client = createSimplifiedVGFClient({
|
|
1000
|
-
* asrRequestConfig: { provider: 'deepgram', language: 'en' },
|
|
1001
|
-
* onStateChange: (state) => {
|
|
1002
|
-
* console.log('VGF State updated:', state);
|
|
1003
|
-
* // Update React state, game UI, etc.
|
|
1004
|
-
* }
|
|
1005
|
-
* });
|
|
1006
|
-
*
|
|
1007
|
-
* // With initial state (e.g., restoring from previous session)
|
|
1008
|
-
* const client = createSimplifiedVGFClient({
|
|
1009
|
-
* asrRequestConfig: { provider: 'deepgram', language: 'en' },
|
|
1010
|
-
* initialState: previousState, // Will use audioUtteranceId from state
|
|
1011
|
-
* onStateChange: (state) => setVGFState(state)
|
|
1012
|
-
* });
|
|
1013
|
-
*
|
|
1014
|
-
* // With initial state containing promptSlotMap for enhanced recognition
|
|
1015
|
-
* const stateWithSlots: RecognitionState = {
|
|
1016
|
-
* audioUtteranceId: 'session-123',
|
|
1017
|
-
* promptSlotMap: {
|
|
1018
|
-
* 'song_title': ['one time', 'baby'],
|
|
1019
|
-
* 'artists': ['justin bieber']
|
|
1020
|
-
* }
|
|
1021
|
-
* };
|
|
1022
|
-
* const client = createSimplifiedVGFClient({
|
|
1023
|
-
* asrRequestConfig: { provider: 'deepgram', language: 'en' },
|
|
1024
|
-
* gameContext: {
|
|
1025
|
-
* type: RecognitionContextTypeV1.GAME_CONTEXT,
|
|
1026
|
-
* gameId: 'music-quiz', // Your game's ID
|
|
1027
|
-
* gamePhase: 'song-guessing' // Current game phase
|
|
1028
|
-
* },
|
|
1029
|
-
* initialState: stateWithSlots, // promptSlotMap will be added to gameContext
|
|
1030
|
-
* onStateChange: (state) => setVGFState(state)
|
|
1031
|
-
* });
|
|
1032
|
-
*
|
|
1033
|
-
* await client.connect();
|
|
1034
|
-
* client.sendAudio(audioData);
|
|
1035
|
-
* // VGF state automatically updates based on transcription results
|
|
1036
|
-
*/
|
|
1037
|
-
declare function createSimplifiedVGFClient(config: SimplifiedVGFClientConfig): ISimplifiedVGFRecognitionClient;
|
|
1038
|
-
|
|
1039
|
-
/**
|
|
1040
|
-
* Base URL schema shared across service endpoint helpers.
|
|
1041
|
-
*/
|
|
1042
|
-
type ServiceBaseUrls = {
|
|
1043
|
-
httpBase: string;
|
|
1044
|
-
wsBase: string;
|
|
1045
|
-
};
|
|
1046
|
-
/**
|
|
1047
|
-
* Base URL mappings keyed by stage.
|
|
1048
|
-
*/
|
|
1049
|
-
declare const RECOGNITION_SERVICE_BASES: Record<Stage, ServiceBaseUrls>;
|
|
1050
|
-
declare const RECOGNITION_CONDUCTOR_BASES: Record<Stage, ServiceBaseUrls>;
|
|
1051
|
-
/**
|
|
1052
|
-
* Normalize arbitrary stage input into a known `Stage`, defaulting to `local`.
|
|
1053
|
-
*/
|
|
1054
|
-
declare function normalizeStage(input?: Stage | string | null | undefined): Stage;
|
|
1055
|
-
/**
|
|
1056
|
-
* Resolve the recognition-service base URLs for a given stage.
|
|
1057
|
-
*/
|
|
1058
|
-
declare function getRecognitionServiceBase(stage?: Stage | string | null | undefined): ServiceBaseUrls;
|
|
1059
|
-
/**
|
|
1060
|
-
* Convenience helper for retrieving the HTTP base URL.
|
|
1061
|
-
*/
|
|
1062
|
-
declare function getRecognitionServiceHttpBase(stage?: Stage | string | null | undefined): string;
|
|
1063
|
-
/**
|
|
1064
|
-
* Convenience helper for retrieving the WebSocket base URL.
|
|
1065
|
-
*/
|
|
1066
|
-
declare function getRecognitionServiceWsBase(stage?: Stage | string | null | undefined): string;
|
|
1067
|
-
/**
|
|
1068
|
-
* Expose hostname lookup separately for callers that need raw host strings.
|
|
1069
|
-
*/
|
|
1070
|
-
declare function getRecognitionServiceHost(stage?: Stage | string | null | undefined): string;
|
|
1071
|
-
/**
|
|
1072
|
-
* Resolve the recognition-conductor base URLs for a given stage.
|
|
1073
|
-
*/
|
|
1074
|
-
declare function getRecognitionConductorBase(stage?: Stage | string | null | undefined): ServiceBaseUrls;
|
|
1075
|
-
declare function getRecognitionConductorHttpBase(stage?: Stage | string | null | undefined): string;
|
|
1076
|
-
declare function getRecognitionConductorWsBase(stage?: Stage | string | null | undefined): string;
|
|
1077
|
-
declare function getRecognitionConductorHost(stage?: Stage | string | null | undefined): string;
|
|
1078
|
-
|
|
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 };
|
|
1
|
+
export { RealTimeTwoWayWebSocketRecognitionClient, type RealTimeTwoWayWebSocketRecognitionClientConfig, type TranscriptionResult, isNormalDisconnection } from './recognition-client.js';
|
|
2
|
+
export { type IRecognitionClient, type IRecognitionClientConfig, type IRecognitionClientStats, type RecognitionCallbackUrl, ClientState } from './recognition-client.types.js';
|
|
3
|
+
export { ConfigBuilder } from './config-builder.js';
|
|
4
|
+
export { createClient, createClientWithBuilder } from './factory.js';
|
|
5
|
+
export { RecognitionError, ConnectionError, TimeoutError, ValidationError } from './errors.js';
|
|
6
|
+
export { ErrorTypeV1 } from '@recog/shared-types';
|
|
7
|
+
export type { RecognitionException, ConnectionException, TimeoutException, ValidationException, AuthenticationException, ProviderException, QuotaExceededException, UnknownException } from '@recog/shared-types';
|
|
8
|
+
export { isExceptionImmediatelyAvailable, getUserFriendlyMessage } from '@recog/shared-types';
|
|
9
|
+
export { SimplifiedVGFRecognitionClient, createSimplifiedVGFClient, type ISimplifiedVGFRecognitionClient, type SimplifiedVGFClientConfig } from './simplified-vgf-recognition-client.js';
|
|
10
|
+
export { type RecognitionState, RecognitionVGFStateSchema, RecordingStatus, TranscriptionStatus, type RecordingStatusType, type TranscriptionStatusType, createInitialRecognitionState, isValidRecordingStatusTransition } from './vgf-recognition-state.js';
|
|
11
|
+
export { AudioEncoding } from '@recog/websocket';
|
|
12
|
+
export { type GameContextV1, type SlotMap, RecognitionContextTypeV1, ControlSignalTypeV1, ControlSignalTypeV1 as ControlSignal, // Alias for backward compatibility
|
|
13
|
+
type TranscriptionResultV1, type FunctionCallResultV1, type MetadataResultV1, type ErrorResultV1, RecognitionResultTypeV1, ClientControlActionV1, type ASRRequestConfig, type ASRRequestV1, FinalTranscriptStability, createDefaultASRConfig, RecognitionProvider, DeepgramModel, GoogleModel, GeminiModel, OpenAIModel, Language, SampleRate, STAGES, type Stage } from '@recog/shared-types';
|
|
14
|
+
export { getRecognitionServiceBase, getRecognitionServiceHttpBase, getRecognitionServiceWsBase, getRecognitionServiceHost, getRecognitionConductorBase, getRecognitionConductorHttpBase, getRecognitionConductorWsBase, getRecognitionConductorHost, normalizeStage, RECOGNITION_SERVICE_BASES, RECOGNITION_CONDUCTOR_BASES } from '@recog/shared-config';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|