@volley/recognition-client-sdk 0.1.800 → 0.1.803
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.bundled.d.ts +8 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -5
- package/dist/index.js.map +2 -2
- package/dist/simplified-vgf-recognition-client.d.ts +1 -2
- package/dist/simplified-vgf-recognition-client.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/index.ts +1 -0
- package/src/simplified-vgf-recognition-client.ts +20 -12
- package/src/vgf-recognition-state.ts +25 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { RecognitionState } from './vgf-recognition-state.js';
|
|
11
11
|
import { IRecognitionClient, IRecognitionClientConfig, IRecognitionClientStats, ClientState } from './recognition-client.types.js';
|
|
12
|
-
import type
|
|
12
|
+
import { type GameContextV1 } from '@recog/shared-types';
|
|
13
13
|
/**
|
|
14
14
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
15
15
|
*/
|
|
@@ -82,7 +82,6 @@ export declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRec
|
|
|
82
82
|
sendGameContext(context: GameContextV1): void;
|
|
83
83
|
isServerReady(): boolean;
|
|
84
84
|
getVGFState(): RecognitionState;
|
|
85
|
-
private isTerminalStatus;
|
|
86
85
|
private notifyStateChange;
|
|
87
86
|
}
|
|
88
87
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplified-vgf-recognition-client.d.ts","sourceRoot":"","sources":["../src/simplified-vgf-recognition-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACH,gBAAgB,
|
|
1
|
+
{"version":3,"file":"simplified-vgf-recognition-client.d.ts","sourceRoot":"","sources":["../src/simplified-vgf-recognition-client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AAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BpC,cAAc,IAAI,IAAI;IAiCtB,mBAAmB,IAAI,MAAM;IAI7B,MAAM,IAAI,MAAM;IAIhB,QAAQ,IAAI,WAAW;IAIvB,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,OAAO;IAIvB,UAAU,IAAI,OAAO;IAIrB,uBAAuB,IAAI,OAAO;IAIlC,mBAAmB,IAAI,OAAO;IAI9B,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7C,aAAa,IAAI,OAAO;IAMxB,WAAW,IAAI,gBAAgB;IAI/B,OAAO,CAAC,iBAAiB;CA8B5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,+BAA+B,CAE5G"}
|
|
@@ -64,6 +64,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
64
64
|
functionCallMetadata: z.ZodOptional<z.ZodString>;
|
|
65
65
|
functionCallConfidence: z.ZodOptional<z.ZodNumber>;
|
|
66
66
|
finalFunctionCallTimestamp: z.ZodOptional<z.ZodString>;
|
|
67
|
+
gameId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
gamePhase: z.ZodOptional<z.ZodString>;
|
|
67
69
|
promptSlotMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
68
70
|
promptSTT: z.ZodOptional<z.ZodString>;
|
|
69
71
|
promptSTF: z.ZodOptional<z.ZodString>;
|
|
@@ -118,6 +120,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
118
120
|
functionCallMetadata?: string | undefined;
|
|
119
121
|
functionCallConfidence?: number | undefined;
|
|
120
122
|
finalFunctionCallTimestamp?: string | undefined;
|
|
123
|
+
gameId?: string | undefined;
|
|
124
|
+
gamePhase?: string | undefined;
|
|
121
125
|
promptSlotMap?: Record<string, string[]> | undefined;
|
|
122
126
|
promptSTT?: string | undefined;
|
|
123
127
|
promptSTF?: string | undefined;
|
|
@@ -160,6 +164,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
160
164
|
functionCallMetadata?: string | undefined;
|
|
161
165
|
functionCallConfidence?: number | undefined;
|
|
162
166
|
finalFunctionCallTimestamp?: string | undefined;
|
|
167
|
+
gameId?: string | undefined;
|
|
168
|
+
gamePhase?: string | undefined;
|
|
163
169
|
promptSlotMap?: Record<string, string[]> | undefined;
|
|
164
170
|
promptSTT?: string | undefined;
|
|
165
171
|
promptSTF?: string | undefined;
|
|
@@ -196,5 +202,6 @@ export declare const RecognitionActionProcessingState: {
|
|
|
196
202
|
};
|
|
197
203
|
export type RecognitionActionProcessingStateType = typeof RecognitionActionProcessingState[keyof typeof RecognitionActionProcessingState];
|
|
198
204
|
export declare function createInitialRecognitionState(audioUtteranceId: string): RecognitionState;
|
|
205
|
+
export declare function isTerminal(state: Pick<RecognitionState, "transcriptionStatus">): boolean;
|
|
199
206
|
export declare function isValidRecordingStatusTransition(from: string | undefined, to: string): boolean;
|
|
200
207
|
//# sourceMappingURL=vgf-recognition-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vgf-recognition-state.d.ts","sourceRoot":"","sources":["../src/vgf-recognition-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"vgf-recognition-state.d.ts","sourceRoot":"","sources":["../src/vgf-recognition-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DpC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAGxE,eAAO,MAAM,eAAe;;;;;CAKlB,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAA;AAEtF,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAA;AAEV,MAAM,MAAM,uBAAuB,GAAG,OAAO,mBAAmB,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAA;AAElG,eAAO,MAAM,gCAAgC;;;;CAInC,CAAA;AAEV,MAAM,MAAM,oCAAoC,GAAG,OAAO,gCAAgC,CAAC,MAAM,OAAO,gCAAgC,CAAC,CAAA;AAGzI,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,GAAG,gBAAgB,CAQxF;AAUD,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,GAAG,OAAO,CAMxF;AAGD,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAa9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volley/recognition-client-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.803",
|
|
4
4
|
"description": "Recognition Service TypeScript/Node.js Client SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"semantic-release": "25.0.1",
|
|
55
55
|
"ts-jest": "29.2.5",
|
|
56
56
|
"typescript": "5.1.6",
|
|
57
|
-
"@recog/shared-config": "1.0.0",
|
|
58
|
-
"@recog/shared-types": "1.0.0",
|
|
59
57
|
"@recog/shared-utils": "1.0.0",
|
|
58
|
+
"@recog/shared-types": "1.0.0",
|
|
59
|
+
"@recog/shared-config": "1.0.0",
|
|
60
60
|
"@recog/websocket": "1.0.0"
|
|
61
61
|
},
|
|
62
62
|
"keywords": [
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
RecognitionState,
|
|
13
13
|
TranscriptionStatus,
|
|
14
14
|
RecordingStatus,
|
|
15
|
-
RecognitionActionProcessingState
|
|
15
|
+
RecognitionActionProcessingState,
|
|
16
|
+
isTerminal
|
|
16
17
|
} from './vgf-recognition-state.js';
|
|
17
18
|
import {
|
|
18
19
|
IRecognitionClient,
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
updateStateOnStop,
|
|
30
31
|
resetRecognitionVGFState
|
|
31
32
|
} from './vgf-recognition-mapper.js';
|
|
32
|
-
import type
|
|
33
|
+
import { RecognitionContextTypeV1, type GameContextV1 } from '@recog/shared-types';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
@@ -139,6 +140,19 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
139
140
|
// Track the expected UUID for this session
|
|
140
141
|
this.expectedUuid = this.state.audioUtteranceId;
|
|
141
142
|
|
|
143
|
+
// Backfill gameContext from state if the caller didn't pass one in config.
|
|
144
|
+
// Lets RecognitionState carry session identity (gameId + gamePhase) alongside
|
|
145
|
+
// runtime prompt inputs (promptSlotMap, promptSTT/STF/TTF), so a single
|
|
146
|
+
// initialState object is sufficient — no separate gameContext required.
|
|
147
|
+
// Backward-compatible: if both are provided, clientConfig.gameContext wins.
|
|
148
|
+
if (!clientConfig.gameContext && this.state.gameId && this.state.gamePhase) {
|
|
149
|
+
clientConfig.gameContext = {
|
|
150
|
+
type: RecognitionContextTypeV1.GAME_CONTEXT,
|
|
151
|
+
gameId: this.state.gameId,
|
|
152
|
+
gamePhase: this.state.gamePhase,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
142
156
|
// Forward optional VGF inputs (promptSlotMap, promptSTT/STF/TTF) into the GameContext.
|
|
143
157
|
const hasPromptInputs =
|
|
144
158
|
this.state.promptSlotMap !== undefined ||
|
|
@@ -153,10 +167,10 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
153
167
|
}
|
|
154
168
|
|
|
155
169
|
if (!clientConfig.gameContext) {
|
|
156
|
-
//
|
|
157
|
-
//
|
|
170
|
+
// No gameContext from config, and state didn't carry gameId+gamePhase
|
|
171
|
+
// either — prompt inputs have nowhere to ride. Warn and drop.
|
|
158
172
|
if (clientConfig.logger) {
|
|
159
|
-
clientConfig.logger('warn', '[VGF] prompt inputs found but no gameContext provided. They will not be sent.');
|
|
173
|
+
clientConfig.logger('warn', '[VGF] prompt inputs found but no gameContext provided and state has no gameId/gamePhase. They will not be sent.');
|
|
160
174
|
}
|
|
161
175
|
} else {
|
|
162
176
|
if (this.state.promptSlotMap !== undefined) {
|
|
@@ -433,16 +447,10 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
433
447
|
return { ...this.state };
|
|
434
448
|
}
|
|
435
449
|
|
|
436
|
-
private isTerminalStatus(status: string | undefined): boolean {
|
|
437
|
-
return status === TranscriptionStatus.FINALIZED ||
|
|
438
|
-
status === TranscriptionStatus.ABORTED ||
|
|
439
|
-
status === TranscriptionStatus.ERROR;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
450
|
private notifyStateChange(): void {
|
|
443
451
|
|
|
444
452
|
// Block duplicate terminal status emissions for THIS session
|
|
445
|
-
if (
|
|
453
|
+
if (isTerminal(this.state)) {
|
|
446
454
|
if (this.lastSentTerminalUuid === this.expectedUuid) {
|
|
447
455
|
// Already sent a terminal status for this session - suppress duplicate
|
|
448
456
|
if (this.logger) {
|
|
@@ -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 = [
|