@volley/recognition-client-sdk 0.1.670 → 0.1.689
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.bundled.d.ts +46 -1
- package/dist/config-builder.d.ts +9 -1
- package/dist/config-builder.d.ts.map +1 -1
- package/dist/index.bundled.d.ts +54 -1
- package/dist/index.js +46 -4
- package/dist/index.js.map +2 -2
- package/dist/recog-client-sdk.browser.js +32 -4
- package/dist/recog-client-sdk.browser.js.map +2 -2
- package/dist/recognition-client.d.ts.map +1 -1
- package/dist/recognition-client.types.d.ts +5 -1
- package/dist/recognition-client.types.d.ts.map +1 -1
- package/dist/utils/message-handler.d.ts +2 -1
- package/dist/utils/message-handler.d.ts.map +1 -1
- package/dist/utils/url-builder.d.ts +2 -0
- package/dist/utils/url-builder.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config-builder.ts +17 -0
- package/src/recognition-client.ts +6 -1
- package/src/recognition-client.types.ts +7 -0
- package/src/utils/message-handler.ts +7 -1
- package/src/utils/url-builder.ts +7 -0
|
@@ -264,7 +264,8 @@ declare enum RecognitionResultTypeV1 {
|
|
|
264
264
|
METADATA = "Metadata",
|
|
265
265
|
ERROR = "Error",
|
|
266
266
|
CLIENT_CONTROL_MESSAGE = "ClientControlMessage",
|
|
267
|
-
AUDIO_METRICS = "AudioMetrics"
|
|
267
|
+
AUDIO_METRICS = "AudioMetrics",
|
|
268
|
+
SESSION_CONFIGURED = "SessionConfigured"
|
|
268
269
|
}
|
|
269
270
|
/**
|
|
270
271
|
* Transcription result V1 - contains transcript message
|
|
@@ -543,6 +544,46 @@ declare const ErrorResultSchemaV1: z.ZodObject<{
|
|
|
543
544
|
description?: string | undefined;
|
|
544
545
|
}>;
|
|
545
546
|
type ErrorResultV1 = z.infer<typeof ErrorResultSchemaV1>;
|
|
547
|
+
/**
|
|
548
|
+
* Session configured message V1 - sent after ASR provider is selected and configured
|
|
549
|
+
* Fires after circuit breaker checks pass and provider/model are finalized,
|
|
550
|
+
* before audio streaming begins. Contains the actual ASR config that will be used.
|
|
551
|
+
*/
|
|
552
|
+
declare const SessionConfiguredSchemaV1: z.ZodObject<{
|
|
553
|
+
type: z.ZodLiteral<RecognitionResultTypeV1.SESSION_CONFIGURED>;
|
|
554
|
+
audioUtteranceId: z.ZodString;
|
|
555
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
556
|
+
model: z.ZodOptional<z.ZodString>;
|
|
557
|
+
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
558
|
+
encoding: z.ZodOptional<z.ZodString>;
|
|
559
|
+
apiType: z.ZodOptional<z.ZodNativeEnum<typeof ASRApiType>>;
|
|
560
|
+
isFallback: z.ZodOptional<z.ZodBoolean>;
|
|
561
|
+
asrRequest: z.ZodOptional<z.ZodString>;
|
|
562
|
+
providerConfig: z.ZodOptional<z.ZodString>;
|
|
563
|
+
}, "strip", z.ZodTypeAny, {
|
|
564
|
+
type: RecognitionResultTypeV1.SESSION_CONFIGURED;
|
|
565
|
+
audioUtteranceId: string;
|
|
566
|
+
provider?: string | undefined;
|
|
567
|
+
model?: string | undefined;
|
|
568
|
+
sampleRate?: number | undefined;
|
|
569
|
+
encoding?: string | undefined;
|
|
570
|
+
apiType?: ASRApiType | undefined;
|
|
571
|
+
isFallback?: boolean | undefined;
|
|
572
|
+
asrRequest?: string | undefined;
|
|
573
|
+
providerConfig?: string | undefined;
|
|
574
|
+
}, {
|
|
575
|
+
type: RecognitionResultTypeV1.SESSION_CONFIGURED;
|
|
576
|
+
audioUtteranceId: string;
|
|
577
|
+
provider?: string | undefined;
|
|
578
|
+
model?: string | undefined;
|
|
579
|
+
sampleRate?: number | undefined;
|
|
580
|
+
encoding?: string | undefined;
|
|
581
|
+
apiType?: ASRApiType | undefined;
|
|
582
|
+
isFallback?: boolean | undefined;
|
|
583
|
+
asrRequest?: string | undefined;
|
|
584
|
+
providerConfig?: string | undefined;
|
|
585
|
+
}>;
|
|
586
|
+
type SessionConfiguredV1 = z.infer<typeof SessionConfiguredSchemaV1>;
|
|
546
587
|
|
|
547
588
|
/**
|
|
548
589
|
* Recognition Context Types V1
|
|
@@ -1102,6 +1143,8 @@ interface IRecognitionClientConfig {
|
|
|
1102
1143
|
questionAnswerId?: string;
|
|
1103
1144
|
/** Platform for audio recording device (optional, e.g., 'ios', 'android', 'web', 'unity') */
|
|
1104
1145
|
platform?: string;
|
|
1146
|
+
/** Experiment cohort (optional). Defaults to 'control' if not provided. */
|
|
1147
|
+
experimentCohort?: 'treatment' | 'control';
|
|
1105
1148
|
/** Callback when transcript is received */
|
|
1106
1149
|
onTranscript?: (result: TranscriptionResultV1) => void;
|
|
1107
1150
|
/**
|
|
@@ -1111,6 +1154,8 @@ interface IRecognitionClientConfig {
|
|
|
1111
1154
|
onFunctionCall?: (result: FunctionCallResultV1) => void;
|
|
1112
1155
|
/** Callback when metadata is received. Only once after transcription is complete.*/
|
|
1113
1156
|
onMetadata?: (metadata: MetadataResultV1) => void;
|
|
1157
|
+
/** Callback when session is configured with actual ASR provider/model (optional) */
|
|
1158
|
+
onSessionConfigured?: (config: SessionConfiguredV1) => void;
|
|
1114
1159
|
/** Callback when error occurs */
|
|
1115
1160
|
onError?: (error: ErrorResultV1) => void;
|
|
1116
1161
|
/** Callback when connected to WebSocket */
|
package/dist/config-builder.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Simple builder pattern for RealTimeTwoWayWebSocketRecognitionClientConfig
|
|
5
5
|
*/
|
|
6
6
|
import type { RealTimeTwoWayWebSocketRecognitionClientConfig, RecognitionCallbackUrl } from './recognition-client.types.js';
|
|
7
|
-
import type { ASRRequestConfig, GameContextV1, TranscriptionResultV1, MetadataResultV1, ErrorResultV1, Stage } from '@recog/shared-types';
|
|
7
|
+
import type { ASRRequestConfig, GameContextV1, TranscriptionResultV1, MetadataResultV1, SessionConfiguredV1, ErrorResultV1, Stage } from '@recog/shared-types';
|
|
8
8
|
/**
|
|
9
9
|
* Builder for RealTimeTwoWayWebSocketRecognitionClientConfig
|
|
10
10
|
*
|
|
@@ -86,6 +86,10 @@ export declare class ConfigBuilder {
|
|
|
86
86
|
* Set platform
|
|
87
87
|
*/
|
|
88
88
|
platform(platform: string): this;
|
|
89
|
+
/**
|
|
90
|
+
* Set experiment cohort (optional, defaults to 'control')
|
|
91
|
+
*/
|
|
92
|
+
experimentCohort(cohort: 'treatment' | 'control'): this;
|
|
89
93
|
/**
|
|
90
94
|
* Set transcript callback
|
|
91
95
|
*/
|
|
@@ -94,6 +98,10 @@ export declare class ConfigBuilder {
|
|
|
94
98
|
* Set metadata callback
|
|
95
99
|
*/
|
|
96
100
|
onMetadata(callback: (metadata: MetadataResultV1) => void): this;
|
|
101
|
+
/**
|
|
102
|
+
* Set session configured callback (optional)
|
|
103
|
+
*/
|
|
104
|
+
onSessionConfigured(callback: (config: SessionConfiguredV1) => void): this;
|
|
97
105
|
/**
|
|
98
106
|
* Set error callback
|
|
99
107
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-builder.d.ts","sourceRoot":"","sources":["../src/config-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,8CAA8C,EAC9C,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,KAAK,EACN,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAA+D;IAE7E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKtB;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI;IAKlC;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAKhD;;OAEG;IACH,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,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAKvG;;OAEG;IACH,KAAK,IAAI,8CAA8C;CAGxD"}
|
package/dist/index.bundled.d.ts
CHANGED
|
@@ -264,7 +264,8 @@ declare enum RecognitionResultTypeV1 {
|
|
|
264
264
|
METADATA = "Metadata",
|
|
265
265
|
ERROR = "Error",
|
|
266
266
|
CLIENT_CONTROL_MESSAGE = "ClientControlMessage",
|
|
267
|
-
AUDIO_METRICS = "AudioMetrics"
|
|
267
|
+
AUDIO_METRICS = "AudioMetrics",
|
|
268
|
+
SESSION_CONFIGURED = "SessionConfigured"
|
|
268
269
|
}
|
|
269
270
|
/**
|
|
270
271
|
* Transcription result V1 - contains transcript message
|
|
@@ -552,6 +553,46 @@ declare enum ClientControlActionV1 {
|
|
|
552
553
|
READY_FOR_UPLOADING_RECORDING = "ready_for_uploading_recording",
|
|
553
554
|
STOP_RECORDING = "stop_recording"
|
|
554
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Session configured message V1 - sent after ASR provider is selected and configured
|
|
558
|
+
* Fires after circuit breaker checks pass and provider/model are finalized,
|
|
559
|
+
* before audio streaming begins. Contains the actual ASR config that will be used.
|
|
560
|
+
*/
|
|
561
|
+
declare const SessionConfiguredSchemaV1: z.ZodObject<{
|
|
562
|
+
type: z.ZodLiteral<RecognitionResultTypeV1.SESSION_CONFIGURED>;
|
|
563
|
+
audioUtteranceId: z.ZodString;
|
|
564
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
565
|
+
model: z.ZodOptional<z.ZodString>;
|
|
566
|
+
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
567
|
+
encoding: z.ZodOptional<z.ZodString>;
|
|
568
|
+
apiType: z.ZodOptional<z.ZodNativeEnum<typeof ASRApiType>>;
|
|
569
|
+
isFallback: z.ZodOptional<z.ZodBoolean>;
|
|
570
|
+
asrRequest: z.ZodOptional<z.ZodString>;
|
|
571
|
+
providerConfig: z.ZodOptional<z.ZodString>;
|
|
572
|
+
}, "strip", z.ZodTypeAny, {
|
|
573
|
+
type: RecognitionResultTypeV1.SESSION_CONFIGURED;
|
|
574
|
+
audioUtteranceId: string;
|
|
575
|
+
provider?: string | undefined;
|
|
576
|
+
model?: string | undefined;
|
|
577
|
+
sampleRate?: number | undefined;
|
|
578
|
+
encoding?: string | undefined;
|
|
579
|
+
apiType?: ASRApiType | undefined;
|
|
580
|
+
isFallback?: boolean | undefined;
|
|
581
|
+
asrRequest?: string | undefined;
|
|
582
|
+
providerConfig?: string | undefined;
|
|
583
|
+
}, {
|
|
584
|
+
type: RecognitionResultTypeV1.SESSION_CONFIGURED;
|
|
585
|
+
audioUtteranceId: string;
|
|
586
|
+
provider?: string | undefined;
|
|
587
|
+
model?: string | undefined;
|
|
588
|
+
sampleRate?: number | undefined;
|
|
589
|
+
encoding?: string | undefined;
|
|
590
|
+
apiType?: ASRApiType | undefined;
|
|
591
|
+
isFallback?: boolean | undefined;
|
|
592
|
+
asrRequest?: string | undefined;
|
|
593
|
+
providerConfig?: string | undefined;
|
|
594
|
+
}>;
|
|
595
|
+
type SessionConfiguredV1 = z.infer<typeof SessionConfiguredSchemaV1>;
|
|
555
596
|
|
|
556
597
|
/**
|
|
557
598
|
* Error Exception Types
|
|
@@ -1862,6 +1903,8 @@ interface IRecognitionClientConfig {
|
|
|
1862
1903
|
questionAnswerId?: string;
|
|
1863
1904
|
/** Platform for audio recording device (optional, e.g., 'ios', 'android', 'web', 'unity') */
|
|
1864
1905
|
platform?: string;
|
|
1906
|
+
/** Experiment cohort (optional). Defaults to 'control' if not provided. */
|
|
1907
|
+
experimentCohort?: 'treatment' | 'control';
|
|
1865
1908
|
/** Callback when transcript is received */
|
|
1866
1909
|
onTranscript?: (result: TranscriptionResultV1) => void;
|
|
1867
1910
|
/**
|
|
@@ -1871,6 +1914,8 @@ interface IRecognitionClientConfig {
|
|
|
1871
1914
|
onFunctionCall?: (result: FunctionCallResultV1) => void;
|
|
1872
1915
|
/** Callback when metadata is received. Only once after transcription is complete.*/
|
|
1873
1916
|
onMetadata?: (metadata: MetadataResultV1) => void;
|
|
1917
|
+
/** Callback when session is configured with actual ASR provider/model (optional) */
|
|
1918
|
+
onSessionConfigured?: (config: SessionConfiguredV1) => void;
|
|
1874
1919
|
/** Callback when error occurs */
|
|
1875
1920
|
onError?: (error: ErrorResultV1) => void;
|
|
1876
1921
|
/** Callback when connected to WebSocket */
|
|
@@ -2297,6 +2342,10 @@ declare class ConfigBuilder {
|
|
|
2297
2342
|
* Set platform
|
|
2298
2343
|
*/
|
|
2299
2344
|
platform(platform: string): this;
|
|
2345
|
+
/**
|
|
2346
|
+
* Set experiment cohort (optional, defaults to 'control')
|
|
2347
|
+
*/
|
|
2348
|
+
experimentCohort(cohort: 'treatment' | 'control'): this;
|
|
2300
2349
|
/**
|
|
2301
2350
|
* Set transcript callback
|
|
2302
2351
|
*/
|
|
@@ -2305,6 +2354,10 @@ declare class ConfigBuilder {
|
|
|
2305
2354
|
* Set metadata callback
|
|
2306
2355
|
*/
|
|
2307
2356
|
onMetadata(callback: (metadata: MetadataResultV1) => void): this;
|
|
2357
|
+
/**
|
|
2358
|
+
* Set session configured callback (optional)
|
|
2359
|
+
*/
|
|
2360
|
+
onSessionConfigured(callback: (config: SessionConfiguredV1) => void): this;
|
|
2308
2361
|
/**
|
|
2309
2362
|
* Set error callback
|
|
2310
2363
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3827,6 +3827,7 @@ var RecognitionResultTypeV1;
|
|
|
3827
3827
|
RecognitionResultTypeV12["ERROR"] = "Error";
|
|
3828
3828
|
RecognitionResultTypeV12["CLIENT_CONTROL_MESSAGE"] = "ClientControlMessage";
|
|
3829
3829
|
RecognitionResultTypeV12["AUDIO_METRICS"] = "AudioMetrics";
|
|
3830
|
+
RecognitionResultTypeV12["SESSION_CONFIGURED"] = "SessionConfigured";
|
|
3830
3831
|
})(RecognitionResultTypeV1 || (RecognitionResultTypeV1 = {}));
|
|
3831
3832
|
var TranscriptionResultSchemaV1 = z.object({
|
|
3832
3833
|
type: z.literal(RecognitionResultTypeV1.TRANSCRIPTION),
|
|
@@ -3948,6 +3949,22 @@ var ClientControlMessageSchemaV1 = z.object({
|
|
|
3948
3949
|
action: ClientControlActionsV1
|
|
3949
3950
|
// The control action to perform
|
|
3950
3951
|
});
|
|
3952
|
+
var SessionConfiguredSchemaV1 = z.object({
|
|
3953
|
+
type: z.literal(RecognitionResultTypeV1.SESSION_CONFIGURED),
|
|
3954
|
+
audioUtteranceId: z.string(),
|
|
3955
|
+
// Provider identification
|
|
3956
|
+
provider: z.string().optional(),
|
|
3957
|
+
model: z.string().optional(),
|
|
3958
|
+
sampleRate: z.number().optional(),
|
|
3959
|
+
encoding: z.string().optional(),
|
|
3960
|
+
apiType: z.nativeEnum(ASRApiType).optional(),
|
|
3961
|
+
isFallback: z.boolean().optional(),
|
|
3962
|
+
// Original ASR request as JSON string (includes prefixMode, prefixId, etc.)
|
|
3963
|
+
asrRequest: z.string().optional(),
|
|
3964
|
+
// Provider-specific config as JSON string (raw config sent to provider API, e.g. Deepgram's punctuate/endpointing)
|
|
3965
|
+
providerConfig: z.string().optional()
|
|
3966
|
+
// Stringified JSON of provider-specific config
|
|
3967
|
+
});
|
|
3951
3968
|
var AudioMetricsResultSchemaV1 = z.object({
|
|
3952
3969
|
type: z.literal(RecognitionResultTypeV1.AUDIO_METRICS),
|
|
3953
3970
|
valid: z.boolean(),
|
|
@@ -3971,7 +3988,8 @@ var RecognitionResultSchemaV1 = z.discriminatedUnion("type", [
|
|
|
3971
3988
|
ErrorResultSchemaV1,
|
|
3972
3989
|
// P1 - P2
|
|
3973
3990
|
FunctionCallResultSchemaV1,
|
|
3974
|
-
ClientControlMessageSchemaV1
|
|
3991
|
+
ClientControlMessageSchemaV1,
|
|
3992
|
+
SessionConfiguredSchemaV1
|
|
3975
3993
|
]);
|
|
3976
3994
|
|
|
3977
3995
|
// ../../libs/types/dist/provider-transcription.types.js
|
|
@@ -4437,8 +4455,9 @@ var RecognitionGameInfoSchema = z.object({
|
|
|
4437
4455
|
questionAskedId: z.string().optional(),
|
|
4438
4456
|
/** @deprecated Use questionAskedId instead. Kept for backward compatibility during migration. */
|
|
4439
4457
|
questionAnswerId: z.string().optional(),
|
|
4440
|
-
platform: z.string().optional()
|
|
4441
|
-
|
|
4458
|
+
platform: z.string().optional(),
|
|
4459
|
+
experimentCohort: z.enum(["treatment", "control"]).optional()
|
|
4460
|
+
// Experiment cohort, defaults to 'control' if not provided
|
|
4442
4461
|
});
|
|
4443
4462
|
var RecognitionQueryMetadataSchema = z.object({
|
|
4444
4463
|
audioUtteranceId: z.string(),
|
|
@@ -5110,6 +5129,9 @@ function buildWebSocketUrl(config) {
|
|
|
5110
5129
|
if (config.gameContext?.gamePhase) {
|
|
5111
5130
|
url.searchParams.set("gamePhase", config.gameContext.gamePhase);
|
|
5112
5131
|
}
|
|
5132
|
+
if (config.experimentCohort) {
|
|
5133
|
+
url.searchParams.set("experimentCohort", config.experimentCohort);
|
|
5134
|
+
}
|
|
5113
5135
|
return url.toString();
|
|
5114
5136
|
}
|
|
5115
5137
|
|
|
@@ -5292,6 +5314,9 @@ var MessageHandler = class {
|
|
|
5292
5314
|
case RecognitionResultTypeV1.CLIENT_CONTROL_MESSAGE:
|
|
5293
5315
|
this.callbacks.onControlMessage(msgData);
|
|
5294
5316
|
break;
|
|
5317
|
+
case RecognitionResultTypeV1.SESSION_CONFIGURED:
|
|
5318
|
+
this.callbacks.onSessionConfigured?.(msgData);
|
|
5319
|
+
break;
|
|
5295
5320
|
default:
|
|
5296
5321
|
if (this.callbacks.logger) {
|
|
5297
5322
|
this.callbacks.logger("debug", "[RecogSDK] Unknown message type", { type: msgType });
|
|
@@ -5403,7 +5428,8 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
5403
5428
|
...config.questionAnswerId && { questionAnswerId: config.questionAnswerId },
|
|
5404
5429
|
...config.platform && { platform: config.platform },
|
|
5405
5430
|
...config.gameContext && { gameContext: config.gameContext },
|
|
5406
|
-
...config.gameId && { gameId: config.gameId }
|
|
5431
|
+
...config.gameId && { gameId: config.gameId },
|
|
5432
|
+
...config.experimentCohort && { experimentCohort: config.experimentCohort }
|
|
5407
5433
|
});
|
|
5408
5434
|
super({
|
|
5409
5435
|
url,
|
|
@@ -5436,6 +5462,7 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
5436
5462
|
}),
|
|
5437
5463
|
onMetadata: config.onMetadata || (() => {
|
|
5438
5464
|
}),
|
|
5465
|
+
onSessionConfigured: config.onSessionConfigured,
|
|
5439
5466
|
onError: config.onError || (() => {
|
|
5440
5467
|
}),
|
|
5441
5468
|
onConnected: config.onConnected || (() => {
|
|
@@ -5463,6 +5490,7 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
5463
5490
|
onMetadata: this.config.onMetadata,
|
|
5464
5491
|
onError: this.config.onError,
|
|
5465
5492
|
onControlMessage: this.handleControlMessage.bind(this),
|
|
5493
|
+
onSessionConfigured: this.config.onSessionConfigured,
|
|
5466
5494
|
...this.config.logger && { logger: this.config.logger }
|
|
5467
5495
|
});
|
|
5468
5496
|
}
|
|
@@ -6106,6 +6134,13 @@ var ConfigBuilder = class {
|
|
|
6106
6134
|
this.config.platform = platform;
|
|
6107
6135
|
return this;
|
|
6108
6136
|
}
|
|
6137
|
+
/**
|
|
6138
|
+
* Set experiment cohort (optional, defaults to 'control')
|
|
6139
|
+
*/
|
|
6140
|
+
experimentCohort(cohort) {
|
|
6141
|
+
this.config.experimentCohort = cohort;
|
|
6142
|
+
return this;
|
|
6143
|
+
}
|
|
6109
6144
|
/**
|
|
6110
6145
|
* Set transcript callback
|
|
6111
6146
|
*/
|
|
@@ -6120,6 +6155,13 @@ var ConfigBuilder = class {
|
|
|
6120
6155
|
this.config.onMetadata = callback;
|
|
6121
6156
|
return this;
|
|
6122
6157
|
}
|
|
6158
|
+
/**
|
|
6159
|
+
* Set session configured callback (optional)
|
|
6160
|
+
*/
|
|
6161
|
+
onSessionConfigured(callback) {
|
|
6162
|
+
this.config.onSessionConfigured = callback;
|
|
6163
|
+
return this;
|
|
6164
|
+
}
|
|
6123
6165
|
/**
|
|
6124
6166
|
* Set error callback
|
|
6125
6167
|
*/
|