@volley/recognition-client-sdk 0.1.385 → 0.1.417
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 +23 -1
- package/dist/config-builder.d.ts +5 -0
- package/dist/config-builder.d.ts.map +1 -1
- package/dist/index.bundled.d.ts +108 -79
- package/dist/index.js +122 -30
- package/dist/index.js.map +4 -4
- package/dist/recog-client-sdk.browser.js +62 -23
- package/dist/recog-client-sdk.browser.js.map +4 -4
- package/dist/recognition-client.d.ts.map +1 -1
- package/dist/recognition-client.types.d.ts +6 -0
- package/dist/recognition-client.types.d.ts.map +1 -1
- package/dist/simplified-vgf-recognition-client.d.ts +2 -0
- package/dist/simplified-vgf-recognition-client.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 +3 -3
- package/src/config-builder.ts +9 -0
- package/src/recognition-client.ts +3 -2
- package/src/recognition-client.types.ts +7 -0
- package/src/simplified-vgf-recognition-client.integration.spec.ts +704 -0
- package/src/simplified-vgf-recognition-client.spec.ts +199 -13
- package/src/simplified-vgf-recognition-client.ts +70 -10
- package/src/utils/audio-ring-buffer.ts +2 -2
- package/src/utils/message-handler.ts +4 -4
- package/src/utils/url-builder.ts +10 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/zod@3.22.
|
|
1
|
+
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
2
2
|
var util;
|
|
3
3
|
(function(util2) {
|
|
4
4
|
util2.assertEqual = (val) => val;
|
|
@@ -3797,6 +3797,7 @@ var RecognitionResultTypeV1;
|
|
|
3797
3797
|
RecognitionResultTypeV12["METADATA"] = "Metadata";
|
|
3798
3798
|
RecognitionResultTypeV12["ERROR"] = "Error";
|
|
3799
3799
|
RecognitionResultTypeV12["CLIENT_CONTROL_MESSAGE"] = "ClientControlMessage";
|
|
3800
|
+
RecognitionResultTypeV12["AUDIO_METRICS"] = "AudioMetrics";
|
|
3800
3801
|
})(RecognitionResultTypeV1 || (RecognitionResultTypeV1 = {}));
|
|
3801
3802
|
var TranscriptionResultSchemaV1 = z.object({
|
|
3802
3803
|
type: z.literal(RecognitionResultTypeV1.TRANSCRIPTION),
|
|
@@ -3821,6 +3822,12 @@ var FunctionCallResultSchemaV1 = z.object({
|
|
|
3821
3822
|
functionName: z.string(),
|
|
3822
3823
|
functionArgJson: z.string()
|
|
3823
3824
|
});
|
|
3825
|
+
var TranscriptOutcomeType;
|
|
3826
|
+
(function(TranscriptOutcomeType2) {
|
|
3827
|
+
TranscriptOutcomeType2["WITH_CONTENT"] = "with_content";
|
|
3828
|
+
TranscriptOutcomeType2["EMPTY"] = "empty";
|
|
3829
|
+
TranscriptOutcomeType2["NEVER_SENT"] = "never_sent";
|
|
3830
|
+
})(TranscriptOutcomeType || (TranscriptOutcomeType = {}));
|
|
3824
3831
|
var MetadataResultSchemaV1 = z.object({
|
|
3825
3832
|
type: z.literal(RecognitionResultTypeV1.METADATA),
|
|
3826
3833
|
audioUtteranceId: z.string(),
|
|
@@ -3840,7 +3847,9 @@ var MetadataResultSchemaV1 = z.object({
|
|
|
3840
3847
|
// ASR configuration as JSON string (no type validation)
|
|
3841
3848
|
asrConfig: z.string().optional(),
|
|
3842
3849
|
// Raw ASR metadata payload as provided by the provider (stringified if needed)
|
|
3843
|
-
rawAsrMetadata: z.string().optional()
|
|
3850
|
+
rawAsrMetadata: z.string().optional(),
|
|
3851
|
+
// Transcript outcome - categorizes the final transcript state
|
|
3852
|
+
transcriptOutcome: z.nativeEnum(TranscriptOutcomeType).optional()
|
|
3844
3853
|
});
|
|
3845
3854
|
var ErrorTypeV1;
|
|
3846
3855
|
(function(ErrorTypeV12) {
|
|
@@ -3873,6 +3882,22 @@ var ClientControlMessageSchemaV1 = z.object({
|
|
|
3873
3882
|
action: ClientControlActionsV1
|
|
3874
3883
|
// The control action to perform
|
|
3875
3884
|
});
|
|
3885
|
+
var AudioMetricsResultSchemaV1 = z.object({
|
|
3886
|
+
type: z.literal(RecognitionResultTypeV1.AUDIO_METRICS),
|
|
3887
|
+
valid: z.boolean(),
|
|
3888
|
+
audioBeginMs: z.number(),
|
|
3889
|
+
audioEndMs: z.number(),
|
|
3890
|
+
maxVolume: z.number(),
|
|
3891
|
+
minVolume: z.number(),
|
|
3892
|
+
avgVolume: z.number(),
|
|
3893
|
+
silenceRatio: z.number(),
|
|
3894
|
+
clippingRatio: z.number(),
|
|
3895
|
+
snrEstimate: z.number().nullable(),
|
|
3896
|
+
lastNonSilenceMs: z.number(),
|
|
3897
|
+
timestamp: z.string(),
|
|
3898
|
+
isFinal: z.boolean().optional()
|
|
3899
|
+
// true if this is the final metrics (STOP_RECORDING signal), false for streaming
|
|
3900
|
+
});
|
|
3876
3901
|
var RecognitionResultSchemaV1 = z.discriminatedUnion("type", [
|
|
3877
3902
|
// P0
|
|
3878
3903
|
TranscriptionResultSchemaV1,
|
|
@@ -4511,6 +4536,7 @@ var PlumbingType;
|
|
|
4511
4536
|
PlumbingType2["PROVIDER_VAD_SIGNAL"] = "provider_vad_signal";
|
|
4512
4537
|
PlumbingType2["PROVIDER_TIMER_SIGNAL"] = "provider_timer_signal";
|
|
4513
4538
|
PlumbingType2["PROVIDER_RAW_MESSAGE"] = "provider_raw_message";
|
|
4539
|
+
PlumbingType2["AUDIO_METRICS"] = "audio_metrics";
|
|
4514
4540
|
})(PlumbingType || (PlumbingType = {}));
|
|
4515
4541
|
|
|
4516
4542
|
// ../../libs/types/dist/game-id.types.js
|
|
@@ -4535,6 +4561,21 @@ var STRING_TO_GAME_ID_MAP = {
|
|
|
4535
4561
|
"twenty-questions": GameId.TWENTY_QUESTIONS,
|
|
4536
4562
|
"emoji": GameId.GUESS_THE_EMOJI
|
|
4537
4563
|
};
|
|
4564
|
+
var GAME_ID_ALIAS_MAP = {
|
|
4565
|
+
// Song Quiz aliases
|
|
4566
|
+
"songquiz": GameId.SONG_QUIZ,
|
|
4567
|
+
"sq": GameId.SONG_QUIZ,
|
|
4568
|
+
// Wheel of Fortune aliases
|
|
4569
|
+
"wof": GameId.WHEEL_OF_FORTUNE,
|
|
4570
|
+
"wheeloffortune": GameId.WHEEL_OF_FORTUNE,
|
|
4571
|
+
// Twenty Questions aliases
|
|
4572
|
+
"20q": GameId.TWENTY_QUESTIONS,
|
|
4573
|
+
"twentyquestions": GameId.TWENTY_QUESTIONS,
|
|
4574
|
+
"20questions": GameId.TWENTY_QUESTIONS,
|
|
4575
|
+
// Guess the Emoji aliases
|
|
4576
|
+
"guesstheemoji": GameId.GUESS_THE_EMOJI,
|
|
4577
|
+
"gte": GameId.GUESS_THE_EMOJI
|
|
4578
|
+
};
|
|
4538
4579
|
|
|
4539
4580
|
// ../../libs/types/dist/gemini-types.js
|
|
4540
4581
|
var GeminiModel;
|
|
@@ -4740,7 +4781,7 @@ var WebSocketAudioClient = class {
|
|
|
4740
4781
|
// ../../libs/websocket/dist/core/audio-upload-websocket-server.js
|
|
4741
4782
|
import { WebSocketServer, WebSocket as WebSocket2 } from "ws";
|
|
4742
4783
|
|
|
4743
|
-
// ../../node_modules/.pnpm/uuid@11.
|
|
4784
|
+
// ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/stringify.js
|
|
4744
4785
|
var byteToHex = [];
|
|
4745
4786
|
for (let i = 0; i < 256; ++i) {
|
|
4746
4787
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -4749,7 +4790,7 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
4749
4790
|
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
4750
4791
|
}
|
|
4751
4792
|
|
|
4752
|
-
// ../../node_modules/.pnpm/uuid@11.
|
|
4793
|
+
// ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/rng.js
|
|
4753
4794
|
var getRandomValues;
|
|
4754
4795
|
var rnds8 = new Uint8Array(16);
|
|
4755
4796
|
function rng() {
|
|
@@ -4762,27 +4803,21 @@ function rng() {
|
|
|
4762
4803
|
return getRandomValues(rnds8);
|
|
4763
4804
|
}
|
|
4764
4805
|
|
|
4765
|
-
// ../../node_modules/.pnpm/uuid@11.
|
|
4806
|
+
// ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/native.js
|
|
4766
4807
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
4767
4808
|
var native_default = { randomUUID };
|
|
4768
4809
|
|
|
4769
|
-
// ../../node_modules/.pnpm/uuid@11.
|
|
4810
|
+
// ../../node_modules/.pnpm/uuid@11.0.0/node_modules/uuid/dist/esm-browser/v4.js
|
|
4770
4811
|
function v4(options, buf, offset) {
|
|
4771
4812
|
if (native_default.randomUUID && !buf && !options) {
|
|
4772
4813
|
return native_default.randomUUID();
|
|
4773
4814
|
}
|
|
4774
4815
|
options = options || {};
|
|
4775
|
-
const rnds = options.random
|
|
4776
|
-
if (rnds.length < 16) {
|
|
4777
|
-
throw new Error("Random bytes length must be >= 16");
|
|
4778
|
-
}
|
|
4816
|
+
const rnds = options.random || (options.rng || rng)();
|
|
4779
4817
|
rnds[6] = rnds[6] & 15 | 64;
|
|
4780
4818
|
rnds[8] = rnds[8] & 63 | 128;
|
|
4781
4819
|
if (buf) {
|
|
4782
4820
|
offset = offset || 0;
|
|
4783
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
4784
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
4785
|
-
}
|
|
4786
4821
|
for (let i = 0; i < 16; ++i) {
|
|
4787
4822
|
buf[offset + i] = rnds[i];
|
|
4788
4823
|
}
|
|
@@ -4875,8 +4910,11 @@ function buildWebSocketUrl(config) {
|
|
|
4875
4910
|
if (config.platform) {
|
|
4876
4911
|
url.searchParams.set("platform", config.platform);
|
|
4877
4912
|
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4913
|
+
const gameId = config.gameId ?? config.gameContext?.gameId;
|
|
4914
|
+
if (gameId) {
|
|
4915
|
+
url.searchParams.set("gameId", gameId);
|
|
4916
|
+
}
|
|
4917
|
+
if (config.gameContext?.gamePhase) {
|
|
4880
4918
|
url.searchParams.set("gamePhase", config.gameContext.gamePhase);
|
|
4881
4919
|
}
|
|
4882
4920
|
return url.toString();
|
|
@@ -4912,7 +4950,7 @@ var AudioRingBuffer = class {
|
|
|
4912
4950
|
this.hasWrapped = true;
|
|
4913
4951
|
this.overflowCount++;
|
|
4914
4952
|
if (this.logger) {
|
|
4915
|
-
this.logger("debug", "Buffer overflow detected", {
|
|
4953
|
+
this.logger("debug", "[RecogSDK] Buffer overflow detected", {
|
|
4916
4954
|
bufferSize: this.bufferSize,
|
|
4917
4955
|
totalOverflows: this.overflowCount,
|
|
4918
4956
|
droppedChunk: this.buffer[this.readIndex]?.timestamp
|
|
@@ -4993,7 +5031,7 @@ var AudioRingBuffer = class {
|
|
|
4993
5031
|
this.chunksBuffered = 0;
|
|
4994
5032
|
this.totalBufferedBytes = 0;
|
|
4995
5033
|
if (this.logger) {
|
|
4996
|
-
this.logger("debug", "Audio buffer cleared");
|
|
5034
|
+
this.logger("debug", "[RecogSDK] Audio buffer cleared");
|
|
4997
5035
|
}
|
|
4998
5036
|
}
|
|
4999
5037
|
/**
|
|
@@ -5028,7 +5066,7 @@ var MessageHandler = class {
|
|
|
5028
5066
|
*/
|
|
5029
5067
|
handleMessage(msg) {
|
|
5030
5068
|
if (this.callbacks.logger) {
|
|
5031
|
-
this.callbacks.logger("debug", "Received WebSocket message", {
|
|
5069
|
+
this.callbacks.logger("debug", "[RecogSDK] Received WebSocket message", {
|
|
5032
5070
|
msgType: msg.type,
|
|
5033
5071
|
msgDataType: msg.data && typeof msg.data === "object" && "type" in msg.data ? msg.data.type : "N/A",
|
|
5034
5072
|
fullMessage: msg
|
|
@@ -5036,7 +5074,7 @@ var MessageHandler = class {
|
|
|
5036
5074
|
}
|
|
5037
5075
|
if (msg.data && typeof msg.data !== "object") {
|
|
5038
5076
|
if (this.callbacks.logger) {
|
|
5039
|
-
this.callbacks.logger("error", "Received primitive msg.data from server", {
|
|
5077
|
+
this.callbacks.logger("error", "[RecogSDK] Received primitive msg.data from server", {
|
|
5040
5078
|
dataType: typeof msg.data,
|
|
5041
5079
|
data: msg.data,
|
|
5042
5080
|
fullMessage: msg
|
|
@@ -5063,7 +5101,7 @@ var MessageHandler = class {
|
|
|
5063
5101
|
break;
|
|
5064
5102
|
default:
|
|
5065
5103
|
if (this.callbacks.logger) {
|
|
5066
|
-
this.callbacks.logger("debug", "Unknown message type", { type: msgType });
|
|
5104
|
+
this.callbacks.logger("debug", "[RecogSDK] Unknown message type", { type: msgType });
|
|
5067
5105
|
}
|
|
5068
5106
|
}
|
|
5069
5107
|
}
|
|
@@ -5076,7 +5114,7 @@ var MessageHandler = class {
|
|
|
5076
5114
|
this.firstTranscriptTime = Date.now();
|
|
5077
5115
|
const timeToFirstTranscript = this.firstTranscriptTime - this.sessionStartTime;
|
|
5078
5116
|
if (this.callbacks.logger) {
|
|
5079
|
-
this.callbacks.logger("debug", "First transcript received", {
|
|
5117
|
+
this.callbacks.logger("debug", "[RecogSDK] First transcript received", {
|
|
5080
5118
|
timeToFirstTranscriptMs: timeToFirstTranscript
|
|
5081
5119
|
});
|
|
5082
5120
|
}
|
|
@@ -5145,7 +5183,8 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
5145
5183
|
...config.accountId && { accountId: config.accountId },
|
|
5146
5184
|
...config.questionAnswerId && { questionAnswerId: config.questionAnswerId },
|
|
5147
5185
|
...config.platform && { platform: config.platform },
|
|
5148
|
-
...config.gameContext && { gameContext: config.gameContext }
|
|
5186
|
+
...config.gameContext && { gameContext: config.gameContext },
|
|
5187
|
+
...config.gameId && { gameId: config.gameId }
|
|
5149
5188
|
});
|
|
5150
5189
|
super({
|
|
5151
5190
|
url,
|
|
@@ -5223,7 +5262,7 @@ var RealTimeTwoWayWebSocketRecognitionClient = class _RealTimeTwoWayWebSocketRec
|
|
|
5223
5262
|
return;
|
|
5224
5263
|
}
|
|
5225
5264
|
if (this.config.logger) {
|
|
5226
|
-
this.config.logger(level, `[
|
|
5265
|
+
this.config.logger(level, `[RecogSDK] ${message}`, data);
|
|
5227
5266
|
}
|
|
5228
5267
|
}
|
|
5229
5268
|
/**
|