@layercode/js-sdk 2.8.2 → 2.8.4
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/README.md +15 -5
- package/dist/layercode-js-sdk.esm.js +345 -242
- package/dist/layercode-js-sdk.esm.js.map +1 -1
- package/dist/layercode-js-sdk.min.js +345 -242
- package/dist/layercode-js-sdk.min.js.map +1 -1
- package/dist/types/index.d.ts +21 -3
- package/dist/types/interfaces.d.ts +6 -2
- package/dist/types/wavtools/lib/analysis/audio_analysis.d.ts +1 -1
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ interface ILayercodeClient {
|
|
|
55
55
|
default: boolean;
|
|
56
56
|
}>) => void;
|
|
57
57
|
mute(): void;
|
|
58
|
-
unmute(): void
|
|
58
|
+
unmute(): Promise<void>;
|
|
59
59
|
sendClientResponseText(text: string): Promise<void>;
|
|
60
60
|
sendClientResponseData(data: any): Promise<void>;
|
|
61
61
|
readonly status: string;
|
|
@@ -84,6 +84,13 @@ interface LayercodeClientOptions {
|
|
|
84
84
|
audioInput?: boolean;
|
|
85
85
|
/** Whether audio output is enabled. I.e. do we play the sound in the browser client */
|
|
86
86
|
audioOutput?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* When true, defers actual audio hardware initialization (AudioContext, mic permissions)
|
|
89
|
+
* until setAudioInput(true) or setAudioOutput(true) is called.
|
|
90
|
+
* The server will still be told this is a voice session, but no browser audio APIs are touched until needed.
|
|
91
|
+
* This avoids Chrome's autoplay policy blocking AudioContext before user gesture.
|
|
92
|
+
*/
|
|
93
|
+
deferAudioInit?: boolean;
|
|
87
94
|
/** Fired when audio input flag changes */
|
|
88
95
|
audioInputChanged?: (audioInput: boolean) => void;
|
|
89
96
|
/** Fired when audio output flag changes */
|
|
@@ -147,6 +154,7 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
147
154
|
private recorderStarted;
|
|
148
155
|
private readySent;
|
|
149
156
|
private currentTurnId;
|
|
157
|
+
private sentReplayFinishedForDisabledOutput;
|
|
150
158
|
private audioBuffer;
|
|
151
159
|
private vadConfig;
|
|
152
160
|
private deviceId;
|
|
@@ -158,6 +166,7 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
158
166
|
private stopRecorderAmplitude?;
|
|
159
167
|
private deviceChangeListener;
|
|
160
168
|
private recorderRestartChain;
|
|
169
|
+
private _skipFirstDeviceCallback;
|
|
161
170
|
private deviceListenerReady;
|
|
162
171
|
private resolveDeviceListenerReady;
|
|
163
172
|
_websocketUrl: string;
|
|
@@ -218,6 +227,12 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
218
227
|
private _stopPlayerAmplitudeMonitoring;
|
|
219
228
|
private _stopRecorderAmplitudeMonitoring;
|
|
220
229
|
audioInputConnect(): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Starts the recorder with a specific device (or default if undefined)
|
|
232
|
+
* This is the single point where getUserMedia is called during initial setup.
|
|
233
|
+
* Idempotent: returns early if recorder is already started or has a live stream.
|
|
234
|
+
*/
|
|
235
|
+
private _startRecorderWithDevice;
|
|
221
236
|
audioInputDisconnect(): Promise<void>;
|
|
222
237
|
setAudioInput(state: boolean): Promise<void>;
|
|
223
238
|
setAudioOutput(state: boolean): Promise<void>;
|
|
@@ -270,7 +285,6 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
270
285
|
*/
|
|
271
286
|
private _restartAudioRecording;
|
|
272
287
|
private _queueRecorderRestart;
|
|
273
|
-
private _initializeRecorderWithDefaultDevice;
|
|
274
288
|
/**
|
|
275
289
|
* Disconnect VAD
|
|
276
290
|
*/
|
|
@@ -286,6 +300,10 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
286
300
|
private _teardownDeviceListeners;
|
|
287
301
|
private _performDisconnectCleanup;
|
|
288
302
|
private _getDeviceComparisonKey;
|
|
303
|
+
private _getUserActivationState;
|
|
304
|
+
private _isMicrophonePermissionDenied;
|
|
305
|
+
private _microphonePermissionDeniedError;
|
|
306
|
+
private _shouldWarnAudioDevicesRequireUserGesture;
|
|
289
307
|
/**
|
|
290
308
|
* Mutes the microphone to stop sending audio to the server
|
|
291
309
|
* The connection and recording remain active for quick unmute
|
|
@@ -294,7 +312,7 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
294
312
|
/**
|
|
295
313
|
* Unmutes the microphone to resume sending audio to the server
|
|
296
314
|
*/
|
|
297
|
-
unmute(): void
|
|
315
|
+
unmute(): Promise<void>;
|
|
298
316
|
}
|
|
299
317
|
export default LayercodeClient;
|
|
300
318
|
export type { ILayercodeClient, LayercodeClientOptions, AuthorizeSessionRequest, AuthorizeSessionRequestParams };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type LayercodeMessageType = 'client.audio' | 'trigger.turn.start' | 'trigger.turn.end' | 'trigger.response.audio.replay_finished' | 'vad_events' | 'client.ready' | 'client.response.text' | 'client.response.data' | 'turn.start' | 'response.audio' | 'response.text' | 'response.data' | 'user.transcript.interim_delta' | 'user.transcript.delta' | 'user.transcript';
|
|
1
|
+
export type LayercodeMessageType = 'client.audio' | 'trigger.turn.start' | 'trigger.turn.end' | 'trigger.response.audio.replay_finished' | 'vad_events' | 'client.ready' | 'client.response.text' | 'client.response.data' | 'turn.start' | 'response.audio' | 'response.text' | 'response.data' | 'response.end' | 'user.transcript.interim_delta' | 'user.transcript.delta' | 'user.transcript';
|
|
2
2
|
export interface BaseLayercodeMessage {
|
|
3
3
|
type: LayercodeMessageType;
|
|
4
4
|
event_id?: string;
|
|
@@ -68,6 +68,10 @@ export interface ServerResponseUserTranscript extends BaseLayercodeMessage {
|
|
|
68
68
|
content: string;
|
|
69
69
|
turn_id: string;
|
|
70
70
|
}
|
|
71
|
-
export
|
|
71
|
+
export interface ServerResponseEndMessage extends BaseLayercodeMessage {
|
|
72
|
+
type: 'response.end';
|
|
73
|
+
turn_id: string;
|
|
74
|
+
}
|
|
75
|
+
export type ServerMessage = ServerTurnMessage | ServerResponseAudioMessage | ServerResponseTextMessage | ServerResponseDataMessage | ServerResponseEndMessage | ServerResponseUserTranscriptInterimDelta | ServerResponseUserTranscriptDelta | ServerResponseUserTranscript;
|
|
72
76
|
export type ClientMessage = ClientAudioMessage | ClientTriggerTurnMessage | ClientTriggerResponseAudioReplayFinishedMessage | ClientVadEventsMessage | ClientReadyMessage | ClientResponseTextMessage | ClientResponseDataMessage;
|
|
73
77
|
export type LayercodeMessage = ClientMessage | ServerMessage;
|
|
@@ -31,7 +31,7 @@ export class AudioAnalysis {
|
|
|
31
31
|
constructor(audioElement: HTMLAudioElement, audioBuffer?: AudioBuffer | null);
|
|
32
32
|
fftResults: any[];
|
|
33
33
|
audio: HTMLAudioElement;
|
|
34
|
-
context:
|
|
34
|
+
context: AudioContext | OfflineAudioContext;
|
|
35
35
|
analyser: AnalyserNode;
|
|
36
36
|
sampleRate: number;
|
|
37
37
|
audioBuffer: AudioBuffer | null;
|
package/package.json
CHANGED