@layercode/js-sdk 2.2.0 → 2.3.1

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.
@@ -1,3 +1,32 @@
1
+ export interface AgentConfig {
2
+ transcription: {
3
+ trigger: 'push_to_talk' | 'automatic';
4
+ can_interrupt: boolean;
5
+ automatic: boolean;
6
+ };
7
+ vad?: {
8
+ enabled?: boolean;
9
+ gate_audio?: boolean;
10
+ buffer_frames?: number;
11
+ model?: string;
12
+ positive_speech_threshold?: number;
13
+ negative_speech_threshold?: number;
14
+ redemption_frames?: number;
15
+ min_speech_frames?: number;
16
+ pre_speech_pad_frames?: number;
17
+ frame_samples?: number;
18
+ };
19
+ }
20
+ interface AuthorizeSessionRequestParams {
21
+ url: string;
22
+ body: {
23
+ agent_id: string;
24
+ metadata: Record<string, any>;
25
+ sdk_version: string;
26
+ conversation_id?: string | null;
27
+ };
28
+ }
29
+ type AuthorizeSessionRequest = (params: AuthorizeSessionRequestParams) => Promise<Response>;
1
30
  /**
2
31
  * Interface for LayercodeClient public methods
3
32
  */
@@ -30,13 +59,16 @@ interface LayercodeClientOptions {
30
59
  conversationId?: string | null;
31
60
  /** The endpoint URL for the audio agent API */
32
61
  authorizeSessionEndpoint: string;
62
+ /** Optional custom request handler for authorizing a session */
63
+ authorizeSessionRequest?: AuthorizeSessionRequest;
33
64
  /** Metadata to send with webhooks */
34
65
  metadata?: Record<string, any>;
35
66
  /** Milliseconds before resuming assistant audio after temporary pause due to user interruption (which was actually a false interruption) */
36
67
  vadResumeDelay?: number;
37
68
  /** Callback when connection is established */
38
- onConnect?: ({ conversationId }: {
69
+ onConnect?: ({ conversationId, config }: {
39
70
  conversationId: string | null;
71
+ config?: AgentConfig;
40
72
  }) => void;
41
73
  /** Callback when connection is closed */
42
74
  onDisconnect?: () => void;
@@ -187,4 +219,4 @@ declare class LayercodeClient implements ILayercodeClient {
187
219
  unmute(): void;
188
220
  }
189
221
  export default LayercodeClient;
190
- export type { ILayercodeClient, LayercodeClientOptions };
222
+ export type { ILayercodeClient, LayercodeClientOptions, AuthorizeSessionRequest, AuthorizeSessionRequestParams };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Layercode",
3
3
  "license": "MIT",
4
4
  "name": "@layercode/js-sdk",
5
- "version": "2.2.0",
5
+ "version": "2.3.1",
6
6
  "description": "Layercode JavaScript SDK for browser usage",
7
7
  "type": "module",
8
8
  "main": "dist/layercode-js-sdk.esm.js",
@@ -48,4 +48,4 @@
48
48
  "@ricky0123/vad-web": "^0.0.24",
49
49
  "onnxruntime-web": "^1.21.1"
50
50
  }
51
- }
51
+ }