@volley/recognition-client-sdk 0.1.800 → 0.1.806
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 +71 -1
- package/dist/config-builder.d.ts +10 -1
- package/dist/config-builder.d.ts.map +1 -1
- package/dist/index.bundled.d.ts +140 -33
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -14
- package/dist/index.js.map +4 -4
- package/dist/recog-client-sdk.browser.js +38 -9
- 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 +9 -1
- package/dist/recognition-client.types.d.ts.map +1 -1
- package/dist/simplified-vgf-recognition-client.d.ts +54 -2
- package/dist/simplified-vgf-recognition-client.d.ts.map +1 -1
- package/dist/utils/url-builder.d.ts +3 -1
- package/dist/utils/url-builder.d.ts.map +1 -1
- package/dist/vgf-recognition-state.d.ts +7 -0
- package/dist/vgf-recognition-state.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/config-builder.spec.ts +14 -0
- package/src/config-builder.ts +19 -1
- package/src/index.ts +7 -0
- package/src/recognition-client.ts +2 -0
- package/src/recognition-client.types.ts +12 -1
- package/src/simplified-vgf-recognition-client.spec.ts +74 -1
- package/src/simplified-vgf-recognition-client.ts +92 -12
- package/src/utils/url-builder.spec.ts +18 -0
- package/src/utils/url-builder.ts +9 -1
- package/src/vgf-recognition-state.ts +25 -0
package/src/utils/url-builder.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { getRecognitionServiceBase } from '@recog/shared-config';
|
|
7
|
-
import type { GameContextV1, Stage } from '@recog/shared-types';
|
|
7
|
+
import type { GameContextV1, Stage, MicrophoneSourceType } from '@recog/shared-types';
|
|
8
8
|
import type { RecognitionCallbackUrl } from '../recognition-client.types.js';
|
|
9
9
|
|
|
10
10
|
export interface UrlBuilderConfig {
|
|
@@ -17,6 +17,8 @@ export interface UrlBuilderConfig {
|
|
|
17
17
|
deviceId?: string;
|
|
18
18
|
accountId?: string;
|
|
19
19
|
questionAnswerId?: string;
|
|
20
|
+
clientId?: string;
|
|
21
|
+
microphoneSourceType?: MicrophoneSourceType | string;
|
|
20
22
|
platform?: string;
|
|
21
23
|
gameContext?: GameContextV1;
|
|
22
24
|
/** Standalone gameId - takes precedence over gameContext.gameId if both provided */
|
|
@@ -77,6 +79,12 @@ export function buildWebSocketUrl(config: UrlBuilderConfig): string {
|
|
|
77
79
|
if (config.questionAnswerId) {
|
|
78
80
|
url.searchParams.set('questionAnswerId', config.questionAnswerId);
|
|
79
81
|
}
|
|
82
|
+
if (config.clientId) {
|
|
83
|
+
url.searchParams.set('clientId', config.clientId);
|
|
84
|
+
}
|
|
85
|
+
if (config.microphoneSourceType) {
|
|
86
|
+
url.searchParams.set('microphoneSourceType', config.microphoneSourceType);
|
|
87
|
+
}
|
|
80
88
|
if (config.platform) {
|
|
81
89
|
url.searchParams.set('platform', config.platform);
|
|
82
90
|
}
|
|
@@ -46,6 +46,15 @@ export const RecognitionVGFStateSchema = z.object({
|
|
|
46
46
|
functionCallConfidence: z.number().optional(), // Confidence score for the function call.
|
|
47
47
|
finalFunctionCallTimestamp: z.string().optional(), // When the final action after interpreting the transcript was taken. Immutable.
|
|
48
48
|
|
|
49
|
+
// Session identity — when set, the VGF client backfills these into
|
|
50
|
+
// GameContextV1 if the caller didn't pass a `gameContext` in config.
|
|
51
|
+
// Lets RecognitionState be the single source of truth: server seeds
|
|
52
|
+
// `gameId` + `gamePhase` + `promptSlotMap` per player, controller passes
|
|
53
|
+
// the whole state as `initialState`, no separate `gameContext` needed.
|
|
54
|
+
// Backward-compatible: if `gameContext` is also passed in config, it wins.
|
|
55
|
+
gameId: z.string().optional(),
|
|
56
|
+
gamePhase: z.string().optional(),
|
|
57
|
+
|
|
49
58
|
// Support for prompt slot mapping - passed to recognition context when present
|
|
50
59
|
promptSlotMap: z.record(z.string(), z.array(z.string())).optional(), // Optional map of slot names to prompt values for recognition context
|
|
51
60
|
|
|
@@ -107,6 +116,22 @@ export function createInitialRecognitionState(audioUtteranceId: string): Recogni
|
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
|
|
119
|
+
// Helper for "session ended — no more state updates coming".
|
|
120
|
+
// Terminal states are FINALIZED (clean end with transcript), ABORTED
|
|
121
|
+
// (user cancelled), and ERROR (something failed). Use this anywhere
|
|
122
|
+
// you forward RecognitionState updates to a server thunk: persist
|
|
123
|
+
// every update, but only do cleanup / observability / scoring work
|
|
124
|
+
// after isTerminal(state) is true. Branch on `transcriptionStatus`
|
|
125
|
+
// when the action depends on *which* terminal state (e.g. only score
|
|
126
|
+
// on FINALIZED, only emit "cancelled" telemetry on ABORTED).
|
|
127
|
+
export function isTerminal(state: Pick<RecognitionState, "transcriptionStatus">): boolean {
|
|
128
|
+
return (
|
|
129
|
+
state.transcriptionStatus === TranscriptionStatus.FINALIZED ||
|
|
130
|
+
state.transcriptionStatus === TranscriptionStatus.ABORTED ||
|
|
131
|
+
state.transcriptionStatus === TranscriptionStatus.ERROR
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
110
135
|
// Helper function to validate state transitions
|
|
111
136
|
export function isValidRecordingStatusTransition(from: string | undefined, to: string): boolean {
|
|
112
137
|
const statusOrder = [
|