@glydeunity/voice-sdk 1.5.20 → 1.5.23

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
@@ -656,6 +656,10 @@ export declare class GlydeVoice {
656
656
  private readonly inputSampleRate;
657
657
  private isAgentSpeaking;
658
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;
659
663
  private conversationHistory;
660
664
  private sessionContext;
661
665
  /**
@@ -670,10 +674,17 @@ export declare class GlydeVoice {
670
674
  */
671
675
  private getAuthHeaders;
672
676
  /**
673
- * Fetch voice configuration from Unity API
677
+ * Fetch voice configuration from Unity API for the current config context.
674
678
  * @returns Voice configuration including system prompt, tools, and Deepgram settings
675
679
  */
676
680
  private fetchConfig;
681
+ /**
682
+ * Fetch voice configuration from Unity API for a given context (e.g. for context switch).
683
+ * @param contextType - Voice context type
684
+ * @param contextId - Optional context ID (required for screening; candidate_uuid for candidate_discover)
685
+ * @returns Voice configuration including system prompt and Deepgram settings
686
+ */
687
+ private fetchConfigForContext;
677
688
  /**
678
689
  * Initialize and start the voice session
679
690
  */
@@ -795,10 +806,28 @@ export declare class GlydeVoice {
795
806
  contextType?: VoiceContextType_2;
796
807
  currentJobUuid?: string;
797
808
  }): void;
809
+ /**
810
+ * If a context reinit was pending (after context_switch), run it now. Called when the agent
811
+ * stops speaking (playback buffer empty) or when the fallback timeout fires.
812
+ * Prefers smooth update (UpdatePrompt) over full reinit; falls back to reinit if update fails.
813
+ */
814
+ private tryFlushPendingContextReinit;
815
+ /**
816
+ * Update context and system prompt in-place over the existing WebSocket (no reconnect).
817
+ * Fetches the new config from Unity, sends Deepgram UpdatePrompt so the agent uses the new
818
+ * instructions, and updates local config/sessionContext. Function calls will then send the
819
+ * new context to the backend. Smoother UX than full reinitialize.
820
+ *
821
+ * @param contextType - New voice context type (e.g. 'screening', 'candidate_discover')
822
+ * @param contextId - New context ID (e.g. application_uuid, candidate_uuid)
823
+ * @throws If WebSocket is not open or config fetch fails
824
+ */
825
+ updateContextAndPrompt(contextType: VoiceContextType_2, contextId: string): Promise<void>;
798
826
  /**
799
827
  * Reinitialize the voice session with a new context (e.g. after context_switch from the server).
800
828
  * Stops the current session, updates config and session context, then starts a new session
801
829
  * so chat history is stored under the correct application/placeholder.
830
+ * Use updateContextAndPrompt for a smoother UX when the WebSocket is already open.
802
831
  *
803
832
  * @param contextType - New voice context type (e.g. 'screening', 'candidate_discover')
804
833
  * @param contextId - New context ID (e.g. application_uuid, candidate_uuid)