@glydeunity/voice-sdk 1.5.18 → 1.5.21

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.d.ts CHANGED
@@ -323,6 +323,15 @@ export declare const componentStyles: {
323
323
  };
324
324
  };
325
325
 
326
+ /**
327
+ * Payload when the server requests a context switch (e.g. screening -> candidate_discover or after create_application).
328
+ * contextType may be any server-returned context (e.g. 'screening', 'candidate_discover').
329
+ */
330
+ export declare interface ContextSwitchPayload {
331
+ contextType: string;
332
+ contextId: string;
333
+ }
334
+
326
335
  /**
327
336
  * Conversation summary from Unity API
328
337
  */
@@ -647,6 +656,10 @@ export declare class GlydeVoice {
647
656
  private readonly inputSampleRate;
648
657
  private isAgentSpeaking;
649
658
  private agentAudioDoneReceived;
659
+ /** Pending context reinit after context_switch; run when agent stops speaking or after fallback timeout */
660
+ private pendingContextReinit;
661
+ private pendingContextReinitFallbackTimer;
662
+ private static readonly PENDING_REINIT_FALLBACK_MS;
650
663
  private conversationHistory;
651
664
  private sessionContext;
652
665
  /**
@@ -786,6 +799,20 @@ export declare class GlydeVoice {
786
799
  contextType?: VoiceContextType_2;
787
800
  currentJobUuid?: string;
788
801
  }): void;
802
+ /**
803
+ * If a context reinit was pending (after context_switch), run it now. Called when the agent
804
+ * stops speaking (playback buffer empty) or when the fallback timeout fires.
805
+ */
806
+ private tryFlushPendingContextReinit;
807
+ /**
808
+ * Reinitialize the voice session with a new context (e.g. after context_switch from the server).
809
+ * Stops the current session, updates config and session context, then starts a new session
810
+ * so chat history is stored under the correct application/placeholder.
811
+ *
812
+ * @param contextType - New voice context type (e.g. 'screening', 'candidate_discover')
813
+ * @param contextId - New context ID (e.g. application_uuid, candidate_uuid)
814
+ */
815
+ reinitializeWithContext(contextType: VoiceContextType_2, contextId: string): Promise<void>;
789
816
  }
790
817
 
791
818
  /**
@@ -845,7 +872,7 @@ declare interface GlydeVoiceConfig_2 {
845
872
  /** DOM element to render the widget UI (optional) */
846
873
  container?: HTMLElement | string;
847
874
  /** Event callback for voice agent events */
848
- onEvent?: (event: VoiceEvent_2) => void;
875
+ onEvent?: (event: VoiceEvent) => void;
849
876
  /** Transcript callback for conversation text */
850
877
  onTranscript?: (text: string, role: 'user' | 'agent') => void;
851
878
  /** Previous conversation history to continue the conversation */
@@ -1250,52 +1277,6 @@ declare interface VoiceConfig_2 {
1250
1277
  */
1251
1278
  export declare type VoiceContextType = 'screening' | 'recruiter' | 'custom' | 'phone';
1252
1279
 
1253
- /**
1254
- * GlydeVoice SDK - Voice Agent Client for GLYDE Unity
1255
- *
1256
- * Provides voice interaction capabilities with GLYDE AI agents through Deepgram Voice API.
1257
- * Supports multiple authentication methods: publishableKey, apiKey, and JWT token.
1258
- *
1259
- * Context Types:
1260
- * - screening: Known candidate with application_uuid - screening interview
1261
- * - recruiter: Internal recruiter copilot
1262
- * - custom: Custom context with overridden prompts
1263
- * - phone: Phone agent context
1264
- * - discovery: Unknown candidate, no job - guide to opportunities (publishable_key only)
1265
- * - job_apply: Unknown candidate, known job - apply to specific job (contextId = job_uuid)
1266
- * - candidate_discover: Known candidate (OTP verified), no job - explore opportunities (contextId = candidate_uuid)
1267
- * - candidate_apply: Known candidate, known job - apply and start screening (contextId = candidate_uuid:job_uuid)
1268
- *
1269
- * @example
1270
- * // Screening interview for existing application
1271
- * const voice = new GlydeVoice({
1272
- * publishableKey: 'pk_...',
1273
- * contextType: 'screening',
1274
- * contextId: 'application-uuid'
1275
- * });
1276
- *
1277
- * @example
1278
- * // Discovery mode - unknown candidate exploring opportunities
1279
- * const voice = new GlydeVoice({
1280
- * publishableKey: 'pk_...',
1281
- * contextType: 'discovery'
1282
- * });
1283
- *
1284
- * @example
1285
- * // Job apply - unknown candidate applying to specific job
1286
- * const voice = new GlydeVoice({
1287
- * publishableKey: 'pk_...',
1288
- * contextType: 'job_apply',
1289
- * contextId: 'job-uuid'
1290
- * });
1291
- *
1292
- * @example
1293
- * // Using JWT token (GLYDEBuddy Teams app)
1294
- * const voice = new GlydeVoice({
1295
- * authToken: userSession.accessToken,
1296
- * contextType: 'recruiter'
1297
- * });
1298
- */
1299
1280
  /**
1300
1281
  * Voice context types supported by the voice agent
1301
1282
  * - screening: Known candidate with application_uuid - screening interview
@@ -1313,15 +1294,7 @@ declare type VoiceContextType_2 = 'screening' | 'recruiter' | 'custom' | 'phone'
1313
1294
  * Voice events emitted by the agent
1314
1295
  */
1315
1296
  export declare interface VoiceEvent {
1316
- type: 'open' | 'close' | 'error' | 'ready' | 'user_speaking' | 'agent_speaking' | 'microphone_ready' | 'transcript' | 'agent_audio';
1317
- payload?: unknown;
1318
- }
1319
-
1320
- /**
1321
- * Voice events emitted by the agent
1322
- */
1323
- declare interface VoiceEvent_2 {
1324
- type: 'open' | 'close' | 'error' | 'ready' | 'user_speaking' | 'agent_speaking' | 'microphone_ready' | 'transcript' | 'agent_audio';
1297
+ type: 'open' | 'close' | 'error' | 'ready' | 'user_speaking' | 'agent_speaking' | 'microphone_ready' | 'transcript' | 'agent_audio' | 'context_switch';
1325
1298
  payload?: unknown;
1326
1299
  }
1327
1300