@glydeunity/voice-sdk 1.6.24 → 1.6.27

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
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * ### 1. CDN Users (Minimal Code)
9
9
  * ```html
10
- * <script src="https://cdn.glyde.com/voice-sdk/v1.4.0/glyde-chat.umd.js"></script>
10
+ * <script src="https://unpkg.com/@glydeunity/voice-sdk@latest/dist/glyde-chat.umd.js"></script>
11
11
  * <script>
12
12
  * GlydeChat.init({
13
13
  * publishableKey: 'pk_...',
@@ -39,6 +39,21 @@ import { default as default_2 } from 'react';
39
39
  */
40
40
  export declare const ActivityIcon: default_2.FC<IconProps>;
41
41
 
42
+ /**
43
+ * Agent metadata returned by the voice config endpoint.
44
+ * Used to populate dynamic headers in both VoiceChat and TextChat.
45
+ */
46
+ export declare interface AgentMetadata {
47
+ /** Display name for the AI agent (e.g. "Chris") */
48
+ agent_name?: string;
49
+ /** Company or staffing agency name (e.g. "Acme Staffing") */
50
+ company_name?: string;
51
+ /** Job title when in a job-specific context */
52
+ job_title?: string;
53
+ /** Greeting phrase (server-controlled first message) */
54
+ greeting?: string;
55
+ }
56
+
42
57
  /**
43
58
  * Authentication method used by the client
44
59
  */
@@ -556,42 +571,6 @@ declare interface ConversationSummaryResponse {
556
571
  * Deepgram agent configuration for LLM and voice settings
557
572
  */
558
573
  export declare interface DeepgramAgentConfig {
559
- tags?: string[];
560
- think?: {
561
- provider?: {
562
- type: string;
563
- model?: string;
564
- };
565
- functions?: Array<{
566
- name: string;
567
- description: string;
568
- parameters: unknown;
569
- endpoint?: {
570
- url: string;
571
- method?: string;
572
- headers?: Record<string, string>;
573
- };
574
- }>;
575
- };
576
- speak?: {
577
- provider?: {
578
- type: string;
579
- model?: string;
580
- };
581
- };
582
- listen?: {
583
- provider?: {
584
- type: string;
585
- model?: string;
586
- version?: string;
587
- };
588
- };
589
- }
590
-
591
- /**
592
- * Deepgram agent configuration for LLM and voice settings
593
- */
594
- declare interface DeepgramAgentConfig_2 {
595
574
  tags?: string[];
596
575
  /** Greeting phrase for the agent (server-controlled). Only used when provided by server. */
597
576
  greeting?: string;
@@ -756,6 +735,7 @@ export declare class GlydeText extends BaseGlydeClient<GlydeTextConfig, TextChat
756
735
  private conversationSummary;
757
736
  private contextSwitchManager;
758
737
  private currentContextType;
738
+ private agentMetadata;
759
739
  /**
760
740
  * Create a new GlydeText instance
761
741
  * @param config - Configuration options
@@ -837,16 +817,20 @@ export declare class GlydeText extends BaseGlydeClient<GlydeTextConfig, TextChat
837
817
  * @returns True if initialized
838
818
  */
839
819
  getIsInitialized(): boolean;
840
- /**
841
- * Alias for isInitialized() for backward compatibility
842
- * @returns True if initialized
843
- * @deprecated Use isInitialized() from base class instead
844
- */
845
- isInitialized(): boolean;
846
820
  /**
847
821
  * Get the current context type
848
822
  */
849
823
  getContextType(): VoiceContextType;
824
+ /**
825
+ * Fetch agent metadata from the voice config endpoint.
826
+ * Populates `agentMetadata` with agent name, company, job title, and greeting.
827
+ * Called during initialize(); failures are non-fatal.
828
+ */
829
+ fetchMetadata(): Promise<AgentMetadata | null>;
830
+ /**
831
+ * Get the agent metadata (available after initialize or fetchMetadata)
832
+ */
833
+ getAgentMetadata(): AgentMetadata | null;
850
834
  /**
851
835
  * Perform smooth context update (no full reinit)
852
836
  * For text chat, this just updates internal state
@@ -908,9 +892,7 @@ export declare interface GlydeTextConfig extends BaseGlydeConfig {
908
892
  * - Playback: AudioWorklet (audio-playback-processor.js) with ring buffer
909
893
  * - Ring buffer enables instant interruption (clear buffer when user speaks)
910
894
  */
911
- export declare class GlydeVoice {
912
- private config;
913
- private unityUrl;
895
+ export declare class GlydeVoice extends BaseGlydeClient<GlydeVoiceConfig, VoiceEvent> {
914
896
  private active;
915
897
  private serverConfig;
916
898
  private ws;
@@ -924,23 +906,14 @@ export declare class GlydeVoice {
924
906
  private readonly inputSampleRate;
925
907
  private isAgentSpeaking;
926
908
  private agentAudioDoneReceived;
927
- /** Pending context reinit after context_switch; run when agent stops speaking or after fallback timeout */
928
- private pendingContextReinit;
929
- private pendingContextReinitFallbackTimer;
930
- private static readonly PENDING_REINIT_FALLBACK_MS;
909
+ private contextSwitchManager;
931
910
  private conversationHistory;
932
911
  private sessionContext;
933
912
  /**
934
913
  * Create a new GlydeVoice instance
935
914
  * @param config - Configuration options
936
915
  */
937
- constructor(config: GlydeVoiceConfig_2);
938
- /**
939
- * Get authentication headers based on configured auth method
940
- * Supports publishableKey, apiKey, and JWT token (authToken)
941
- * @returns Headers object with appropriate authentication
942
- */
943
- private getAuthHeaders;
916
+ constructor(config: GlydeVoiceConfig);
944
917
  /**
945
918
  * Fetch voice configuration from Unity API for the current config context.
946
919
  * @returns Voice configuration including system prompt, tools, and Deepgram settings
@@ -965,10 +938,6 @@ export declare class GlydeVoice {
965
938
  * @returns A blob URL that can be used with audioWorklet.addModule()
966
939
  */
967
940
  private createWorkletBlobUrl;
968
- /**
969
- * Initialize the audio system with both capture and playback worklets.
970
- * Uses inline blob URLs to avoid CORS issues when SDK is embedded in external apps.
971
- */
972
941
  /**
973
942
  * Initialize the audio system: AudioContext, worklet modules, playback node,
974
943
  * and pre-acquire the microphone stream.
@@ -1000,9 +969,6 @@ export declare class GlydeVoice {
1000
969
  * Clear the playback buffer (for interruption handling)
1001
970
  */
1002
971
  private clearPlaybackBuffer;
1003
- /**
1004
- * Start capturing microphone audio using AudioWorklet
1005
- */
1006
972
  /**
1007
973
  * Wire the pre-acquired microphone stream to the capture worklet so audio
1008
974
  * data starts flowing to the WebSocket. The stream itself was already
@@ -1029,7 +995,7 @@ export declare class GlydeVoice {
1029
995
  /**
1030
996
  * Get the current server configuration
1031
997
  */
1032
- getServerConfig(): VoiceConfig_2 | null;
998
+ getServerConfig(): VoiceConfig | null;
1033
999
  /**
1034
1000
  * Stop the voice session
1035
1001
  */
@@ -1039,9 +1005,9 @@ export declare class GlydeVoice {
1039
1005
  */
1040
1006
  private cleanup;
1041
1007
  /**
1042
- * Emit event to callback
1008
+ * Emit event to the configured callback (implements BaseGlydeClient abstract method)
1043
1009
  */
1044
- private emit;
1010
+ protected emitEvent(event: VoiceEvent): void;
1045
1011
  /**
1046
1012
  * Render a simple UI widget (optional)
1047
1013
  */
@@ -1090,12 +1056,6 @@ export declare class GlydeVoice {
1090
1056
  currentJobUuid?: string;
1091
1057
  candidateUuid?: string;
1092
1058
  }): void;
1093
- /**
1094
- * If a context reinit was pending (after context_switch), run it now. Called when the agent
1095
- * stops speaking (playback buffer empty) or when the fallback timeout fires.
1096
- * Prefers smooth update (UpdatePrompt) over full reinit; falls back to reinit if update fails.
1097
- */
1098
- private tryFlushPendingContextReinit;
1099
1059
  /**
1100
1060
  * Update context and system prompt in-place over the existing WebSocket (no reconnect).
1101
1061
  * Fetches the new config from Unity, sends Deepgram UpdatePrompt so the agent uses the new
@@ -1129,34 +1089,6 @@ export declare class GlydeVoice {
1129
1089
  * Configuration options for GlydeVoice
1130
1090
  */
1131
1091
  export declare interface GlydeVoiceConfig extends BaseGlydeConfig {
1132
- /** Voice context type - determines which prompt and tools to use */
1133
- contextType: VoiceContextType;
1134
- /** DOM element to render the widget UI (optional) */
1135
- container?: HTMLElement | string;
1136
- /** Event callback for voice agent events */
1137
- onEvent?: (event: VoiceEvent) => void;
1138
- /** Transcript callback for conversation text */
1139
- onTranscript?: (text: string, role: 'user' | 'agent') => void;
1140
- /** Override system prompt (skips config fetch) */
1141
- systemPrompt?: string;
1142
- /** Override Deepgram configuration */
1143
- deepgramConfig?: DeepgramAgentConfig;
1144
- /** When true, skip last-3-messages continuity limit for screening (e.g. cdn-test) */
1145
- skipContinuityLimit?: boolean;
1146
- /** Max last N messages when skipContinuityLimit is false (default 3; cdn-test use 5; CareerBuddy use 50). */
1147
- limitToLast?: number;
1148
- }
1149
-
1150
- /**
1151
- * Configuration options for GlydeVoice
1152
- */
1153
- declare interface GlydeVoiceConfig_2 {
1154
- /** Publishable key for external apps (Screen) */
1155
- publishableKey?: string;
1156
- /** API key for programmatic access */
1157
- apiKey?: string;
1158
- /** JWT token for GLYDEBuddy passthrough (Teams app) */
1159
- authToken?: string;
1160
1092
  /**
1161
1093
  * Voice context type - determines which prompt and tools to use
1162
1094
  *
@@ -1170,17 +1102,6 @@ declare interface GlydeVoiceConfig_2 {
1170
1102
  * - 'candidate_apply': Known candidate applying to job (contextId = candidate_uuid:job_uuid)
1171
1103
  */
1172
1104
  contextType: VoiceContextType;
1173
- /**
1174
- * Context identifier - format depends on contextType:
1175
- * - screening: application_uuid (required)
1176
- * - job_apply: job_uuid (required)
1177
- * - candidate_discover: candidate_uuid (required)
1178
- * - candidate_apply: "candidate_uuid:job_uuid" (required)
1179
- * - discovery, recruiter, custom, phone: optional
1180
- */
1181
- contextId?: string;
1182
- /** Unity API base URL - defaults to https://api.glydeunity.com */
1183
- unityBaseUrl?: string;
1184
1105
  /** DOM element to render the widget UI (optional) */
1185
1106
  container?: HTMLElement | string;
1186
1107
  /** Event callback for voice agent events */
@@ -1192,16 +1113,12 @@ declare interface GlydeVoiceConfig_2 {
1192
1113
  role: 'user' | 'agent';
1193
1114
  content: string;
1194
1115
  }>;
1195
- /**
1196
- * When true, request full chat history for screening. Default false = server sends only last limitToLast messages.
1197
- */
1116
+ /** When true, skip last-3-messages continuity limit for screening (e.g. cdn-test) */
1198
1117
  skipContinuityLimit?: boolean;
1199
- /**
1200
- * Max last N messages to include when skipContinuityLimit is false (default 3). Use 5 for cdn-test; 50 for CareerBuddy/discovery/candidate_discover.
1201
- */
1118
+ /** Max last N messages when skipContinuityLimit is false (default 3; cdn-test use 5; CareerBuddy use 50). */
1202
1119
  limitToLast?: number;
1203
1120
  /** Override Deepgram configuration (e.g. model, tags). System prompt and greeting remain server-controlled. */
1204
- deepgramConfig?: DeepgramAgentConfig_2;
1121
+ deepgramConfig?: DeepgramAgentConfig;
1205
1122
  /**
1206
1123
  * Additional tool/function definitions to merge with server-provided functions.
1207
1124
  * Server-defined functions are always included; this allows adding extra tools only.
@@ -1257,15 +1174,6 @@ export declare interface MCPTool {
1257
1174
  inputSchema?: unknown;
1258
1175
  }
1259
1176
 
1260
- /**
1261
- * MCP Tool definition for voice agent
1262
- */
1263
- declare interface MCPTool_2 {
1264
- name: string;
1265
- description: string;
1266
- inputSchema?: unknown;
1267
- }
1268
-
1269
1177
  /**
1270
1178
  * Message / chat icon
1271
1179
  */
@@ -1346,8 +1254,6 @@ export declare interface TextChatProps {
1346
1254
  unityApiUrl?: string;
1347
1255
  /** Fixed height for the component */
1348
1256
  height?: string | number;
1349
- /** Header title */
1350
- title?: string;
1351
1257
  /** Placeholder text for input */
1352
1258
  placeholder?: string;
1353
1259
  /** Auto-initialize chat on mount */
@@ -1356,6 +1262,8 @@ export declare interface TextChatProps {
1356
1262
  onMessage?: (message: ChatMessage) => void;
1357
1263
  /** Callback when error occurs */
1358
1264
  onError?: (error: Error) => void;
1265
+ /** Callback when context switches (e.g. screening -> candidate_discover) */
1266
+ onContextSwitch?: (contextType: string, contextId: string) => void;
1359
1267
  }
1360
1268
 
1361
1269
  /**
@@ -1455,6 +1363,8 @@ export declare function useTextChat(config: UseTextChatConfig): UseTextChatRetur
1455
1363
  export declare interface UseTextChatConfig extends Omit<GlydeTextConfig, 'onEvent' | 'onMessage' | 'onTyping'> {
1456
1364
  /** Auto-initialize the chat on mount */
1457
1365
  autoInit?: boolean;
1366
+ /** Callback when context switches (e.g. screening -> candidate_discover) */
1367
+ onContextSwitch?: (payload: ContextSwitchPayload) => void;
1458
1368
  }
1459
1369
 
1460
1370
  /**
@@ -1469,6 +1379,8 @@ export declare interface UseTextChatReturn {
1469
1379
  isLoading: boolean;
1470
1380
  /** Error message if status is 'error' */
1471
1381
  errorMessage: string | null;
1382
+ /** Agent metadata from voice config (agent_name, company_name, etc.) */
1383
+ agentMetadata: AgentMetadata | null;
1472
1384
  /** Initialize the chat session */
1473
1385
  initialize: () => Promise<void>;
1474
1386
  /** Send a message */
@@ -1511,6 +1423,8 @@ export declare interface UseVoiceAgentReturn {
1511
1423
  isMuted: boolean;
1512
1424
  /** Error message if status is 'error' */
1513
1425
  errorMessage: string | null;
1426
+ /** Agent metadata from voice config (agent_name, company_name, etc.) */
1427
+ agentMetadata: AgentMetadata | null;
1514
1428
  /** Start the voice session */
1515
1429
  start: () => Promise<void>;
1516
1430
  /** Stop the voice session */
@@ -1584,19 +1498,8 @@ export declare interface VoiceConfig {
1584
1498
  type: VoiceContextType;
1585
1499
  id: string | null;
1586
1500
  };
1587
- }
1588
-
1589
- /**
1590
- * Voice configuration response from Unity API
1591
- */
1592
- declare interface VoiceConfig_2 {
1593
- system_prompt: string;
1594
- available_tools: MCPTool_2[];
1595
- deepgram_config: DeepgramAgentConfig_2;
1596
- context: {
1597
- type: VoiceContextType;
1598
- id: string | null;
1599
- };
1501
+ /** Agent/company metadata for dynamic UI headers */
1502
+ metadata?: AgentMetadata;
1600
1503
  }
1601
1504
 
1602
1505
  /**