@anganyai/voice-sdk 0.0.2 → 0.0.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/dist/index.cjs +309 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -6
- package/dist/index.d.ts +75 -6
- package/dist/index.js +309 -32
- package/dist/index.js.map +1 -1
- package/package.json +9 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,10 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
interface VoiceConfig {
|
|
8
8
|
/**
|
|
9
|
-
* The base URL of the Angany API
|
|
9
|
+
* The base URL of the Angany API (REST endpoints)
|
|
10
|
+
* Used for authentication, conversation management, and other REST API calls
|
|
10
11
|
* @default 'https://api.angany.ai'
|
|
11
12
|
*/
|
|
12
13
|
apiUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* The base URL for Server-Sent Events (SSE) streaming
|
|
16
|
+
* Used for real-time transcription and event streaming
|
|
17
|
+
* @default Same as apiUrl
|
|
18
|
+
*/
|
|
19
|
+
sseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The WebSocket URL for SIP/WebRTC connections
|
|
22
|
+
* Used for voice communication
|
|
23
|
+
* @default Derived from apiUrl (wss://{apiUrl.hostname}/api/webrtc/)
|
|
24
|
+
*/
|
|
25
|
+
sipUrl?: string;
|
|
13
26
|
/**
|
|
14
27
|
* The OIDC issuer URL
|
|
15
28
|
* @default Same as apiUrl
|
|
@@ -854,6 +867,11 @@ declare class AuthManager extends EventEmitter<AuthEvents> {
|
|
|
854
867
|
getEphemeralCredentialsForUser(userAccessToken: string): Promise<EphemeralCredentials>;
|
|
855
868
|
/**
|
|
856
869
|
* Get ephemeral credentials for WebRTC connections
|
|
870
|
+
*
|
|
871
|
+
* Returns cached credentials if available and valid, otherwise fetches new ones.
|
|
872
|
+
* This supports both:
|
|
873
|
+
* - Externally-provided credentials (via setEphemeralCredentials)
|
|
874
|
+
* - SDK-managed credentials (fetched using access token)
|
|
857
875
|
*/
|
|
858
876
|
getEphemeralCredentials(): Promise<EphemeralCredentials>;
|
|
859
877
|
/**
|
|
@@ -1248,12 +1266,27 @@ interface ConversationEvents extends Record<string, unknown[]> {
|
|
|
1248
1266
|
text: string;
|
|
1249
1267
|
timestamp: Date;
|
|
1250
1268
|
isFinal: boolean;
|
|
1269
|
+
humanTurnId?: string | undefined;
|
|
1270
|
+
agentTurnId?: string | undefined;
|
|
1271
|
+
speakerId?: string | number | undefined;
|
|
1251
1272
|
}
|
|
1252
1273
|
];
|
|
1253
1274
|
/**
|
|
1254
1275
|
* Emitted on error
|
|
1255
1276
|
*/
|
|
1256
1277
|
error: [error: Error];
|
|
1278
|
+
/**
|
|
1279
|
+
* Emitted when call ID is received
|
|
1280
|
+
*/
|
|
1281
|
+
callId: [callId: string];
|
|
1282
|
+
/**
|
|
1283
|
+
* Emitted when call starts
|
|
1284
|
+
*/
|
|
1285
|
+
callStarted: [callId: string];
|
|
1286
|
+
/**
|
|
1287
|
+
* Emitted when call ends
|
|
1288
|
+
*/
|
|
1289
|
+
callEnded: [callId: string];
|
|
1257
1290
|
/**
|
|
1258
1291
|
* Emitted when agent is muted/unmuted
|
|
1259
1292
|
*/
|
|
@@ -1290,6 +1323,17 @@ interface ConversationEvents extends Record<string, unknown[]> {
|
|
|
1290
1323
|
* Conversation management
|
|
1291
1324
|
*/
|
|
1292
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* URL configuration for conversation services
|
|
1328
|
+
*/
|
|
1329
|
+
interface ConversationUrls {
|
|
1330
|
+
/** Base URL for REST API calls */
|
|
1331
|
+
apiUrl: string;
|
|
1332
|
+
/** Base URL for SSE streaming (defaults to apiUrl) */
|
|
1333
|
+
sseUrl?: string | undefined;
|
|
1334
|
+
/** WebSocket URL for SIP/WebRTC (defaults to derived from apiUrl) */
|
|
1335
|
+
sipUrl?: string | undefined;
|
|
1336
|
+
}
|
|
1293
1337
|
/**
|
|
1294
1338
|
* Represents an active voice conversation
|
|
1295
1339
|
*/
|
|
@@ -1302,7 +1346,7 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1302
1346
|
private userMuted;
|
|
1303
1347
|
private startTime?;
|
|
1304
1348
|
private endTime?;
|
|
1305
|
-
private
|
|
1349
|
+
private urls;
|
|
1306
1350
|
private authManager;
|
|
1307
1351
|
private sipManager;
|
|
1308
1352
|
private transcriptionService;
|
|
@@ -1310,7 +1354,7 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1310
1354
|
private callId?;
|
|
1311
1355
|
private ephemeralCredentials?;
|
|
1312
1356
|
private accessToken?;
|
|
1313
|
-
constructor(id: string, options: ConversationOptions, authManager: AuthManager,
|
|
1357
|
+
constructor(id: string, options: ConversationOptions, authManager: AuthManager, urls: ConversationUrls);
|
|
1314
1358
|
/**
|
|
1315
1359
|
* Initialize and start the conversation
|
|
1316
1360
|
*/
|
|
@@ -1319,8 +1363,15 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1319
1363
|
* Send text to be spoken in the conversation
|
|
1320
1364
|
*/
|
|
1321
1365
|
speak(text: string, options?: {
|
|
1322
|
-
|
|
1323
|
-
|
|
1366
|
+
interruptsConversation?: boolean;
|
|
1367
|
+
queueWhenSpeaking?: boolean;
|
|
1368
|
+
muteAgent?: boolean | null;
|
|
1369
|
+
voiceSettings?: {
|
|
1370
|
+
stability?: number;
|
|
1371
|
+
similarity_boost?: number;
|
|
1372
|
+
style?: number;
|
|
1373
|
+
use_speaker_boost?: boolean;
|
|
1374
|
+
} | null;
|
|
1324
1375
|
}): Promise<void>;
|
|
1325
1376
|
/**
|
|
1326
1377
|
* Mute or unmute the user's microphone
|
|
@@ -1338,6 +1389,24 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1338
1389
|
* Check if agent is muted
|
|
1339
1390
|
*/
|
|
1340
1391
|
isAgentMuted(): boolean;
|
|
1392
|
+
/**
|
|
1393
|
+
* Get the current call ID (available after connection)
|
|
1394
|
+
*/
|
|
1395
|
+
getCallId(): string | undefined;
|
|
1396
|
+
/**
|
|
1397
|
+
* Mute the call via API (POST /calls/{call_id}/mute)
|
|
1398
|
+
*/
|
|
1399
|
+
muteCall(): Promise<void>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Unmute the call via API (DELETE /calls/{call_id}/mute)
|
|
1402
|
+
*/
|
|
1403
|
+
unmuteCall(): Promise<void>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Get call mute status via API (GET /calls/{call_id}/mute)
|
|
1406
|
+
*/
|
|
1407
|
+
getCallMuteStatus(): Promise<{
|
|
1408
|
+
muted: boolean;
|
|
1409
|
+
}>;
|
|
1341
1410
|
/**
|
|
1342
1411
|
* Get conversation status
|
|
1343
1412
|
*/
|
|
@@ -1705,4 +1774,4 @@ declare function hasErrorCode(error: unknown, code: string): boolean;
|
|
|
1705
1774
|
*/
|
|
1706
1775
|
declare const VERSION = "0.0.2";
|
|
1707
1776
|
|
|
1708
|
-
export { AnganyError, AnganyVoice, type AuthError, type AuthEvents, AuthManager, type AuthOptions, type AuthState, type AuthStatus, AuthenticationError, type BackendAuthOptions, type ClientCredentials, ConfigurationError, Conversation, ConversationError, type ConversationOptions, type ConversationState, type ConversationStatus, ErrorCodes, EventEmitter, type FrontendAuthOptions, type LogLevel, MediaError, NetworkError, PermissionError, ResourceError, type ServiceAccountAuthOptions, type ServiceAccountCredentials, type SpeakOptions, type TokenSet, type TranscriptionEvent, type UserInfo, VERSION, ValidationError, type VoiceConfig, type VoiceResource, hasErrorCode, isAnganyError };
|
|
1777
|
+
export { AnganyError, AnganyVoice, type AuthError, type AuthEvents, AuthManager, type AuthOptions, type AuthState, type AuthStatus, AuthenticationError, type BackendAuthOptions, type ClientCredentials, ConfigurationError, Conversation, ConversationError, type ConversationOptions, type ConversationState, type ConversationStatus, type ConversationUrls, ErrorCodes, EventEmitter, type FrontendAuthOptions, type LogLevel, MediaError, NetworkError, PermissionError, ResourceError, type ServiceAccountAuthOptions, type ServiceAccountCredentials, type SpeakOptions, type TokenSet, type TranscriptionEvent, type UserInfo, VERSION, ValidationError, type VoiceConfig, type VoiceResource, hasErrorCode, isAnganyError };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
interface VoiceConfig {
|
|
8
8
|
/**
|
|
9
|
-
* The base URL of the Angany API
|
|
9
|
+
* The base URL of the Angany API (REST endpoints)
|
|
10
|
+
* Used for authentication, conversation management, and other REST API calls
|
|
10
11
|
* @default 'https://api.angany.ai'
|
|
11
12
|
*/
|
|
12
13
|
apiUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* The base URL for Server-Sent Events (SSE) streaming
|
|
16
|
+
* Used for real-time transcription and event streaming
|
|
17
|
+
* @default Same as apiUrl
|
|
18
|
+
*/
|
|
19
|
+
sseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The WebSocket URL for SIP/WebRTC connections
|
|
22
|
+
* Used for voice communication
|
|
23
|
+
* @default Derived from apiUrl (wss://{apiUrl.hostname}/api/webrtc/)
|
|
24
|
+
*/
|
|
25
|
+
sipUrl?: string;
|
|
13
26
|
/**
|
|
14
27
|
* The OIDC issuer URL
|
|
15
28
|
* @default Same as apiUrl
|
|
@@ -854,6 +867,11 @@ declare class AuthManager extends EventEmitter<AuthEvents> {
|
|
|
854
867
|
getEphemeralCredentialsForUser(userAccessToken: string): Promise<EphemeralCredentials>;
|
|
855
868
|
/**
|
|
856
869
|
* Get ephemeral credentials for WebRTC connections
|
|
870
|
+
*
|
|
871
|
+
* Returns cached credentials if available and valid, otherwise fetches new ones.
|
|
872
|
+
* This supports both:
|
|
873
|
+
* - Externally-provided credentials (via setEphemeralCredentials)
|
|
874
|
+
* - SDK-managed credentials (fetched using access token)
|
|
857
875
|
*/
|
|
858
876
|
getEphemeralCredentials(): Promise<EphemeralCredentials>;
|
|
859
877
|
/**
|
|
@@ -1248,12 +1266,27 @@ interface ConversationEvents extends Record<string, unknown[]> {
|
|
|
1248
1266
|
text: string;
|
|
1249
1267
|
timestamp: Date;
|
|
1250
1268
|
isFinal: boolean;
|
|
1269
|
+
humanTurnId?: string | undefined;
|
|
1270
|
+
agentTurnId?: string | undefined;
|
|
1271
|
+
speakerId?: string | number | undefined;
|
|
1251
1272
|
}
|
|
1252
1273
|
];
|
|
1253
1274
|
/**
|
|
1254
1275
|
* Emitted on error
|
|
1255
1276
|
*/
|
|
1256
1277
|
error: [error: Error];
|
|
1278
|
+
/**
|
|
1279
|
+
* Emitted when call ID is received
|
|
1280
|
+
*/
|
|
1281
|
+
callId: [callId: string];
|
|
1282
|
+
/**
|
|
1283
|
+
* Emitted when call starts
|
|
1284
|
+
*/
|
|
1285
|
+
callStarted: [callId: string];
|
|
1286
|
+
/**
|
|
1287
|
+
* Emitted when call ends
|
|
1288
|
+
*/
|
|
1289
|
+
callEnded: [callId: string];
|
|
1257
1290
|
/**
|
|
1258
1291
|
* Emitted when agent is muted/unmuted
|
|
1259
1292
|
*/
|
|
@@ -1290,6 +1323,17 @@ interface ConversationEvents extends Record<string, unknown[]> {
|
|
|
1290
1323
|
* Conversation management
|
|
1291
1324
|
*/
|
|
1292
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* URL configuration for conversation services
|
|
1328
|
+
*/
|
|
1329
|
+
interface ConversationUrls {
|
|
1330
|
+
/** Base URL for REST API calls */
|
|
1331
|
+
apiUrl: string;
|
|
1332
|
+
/** Base URL for SSE streaming (defaults to apiUrl) */
|
|
1333
|
+
sseUrl?: string | undefined;
|
|
1334
|
+
/** WebSocket URL for SIP/WebRTC (defaults to derived from apiUrl) */
|
|
1335
|
+
sipUrl?: string | undefined;
|
|
1336
|
+
}
|
|
1293
1337
|
/**
|
|
1294
1338
|
* Represents an active voice conversation
|
|
1295
1339
|
*/
|
|
@@ -1302,7 +1346,7 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1302
1346
|
private userMuted;
|
|
1303
1347
|
private startTime?;
|
|
1304
1348
|
private endTime?;
|
|
1305
|
-
private
|
|
1349
|
+
private urls;
|
|
1306
1350
|
private authManager;
|
|
1307
1351
|
private sipManager;
|
|
1308
1352
|
private transcriptionService;
|
|
@@ -1310,7 +1354,7 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1310
1354
|
private callId?;
|
|
1311
1355
|
private ephemeralCredentials?;
|
|
1312
1356
|
private accessToken?;
|
|
1313
|
-
constructor(id: string, options: ConversationOptions, authManager: AuthManager,
|
|
1357
|
+
constructor(id: string, options: ConversationOptions, authManager: AuthManager, urls: ConversationUrls);
|
|
1314
1358
|
/**
|
|
1315
1359
|
* Initialize and start the conversation
|
|
1316
1360
|
*/
|
|
@@ -1319,8 +1363,15 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1319
1363
|
* Send text to be spoken in the conversation
|
|
1320
1364
|
*/
|
|
1321
1365
|
speak(text: string, options?: {
|
|
1322
|
-
|
|
1323
|
-
|
|
1366
|
+
interruptsConversation?: boolean;
|
|
1367
|
+
queueWhenSpeaking?: boolean;
|
|
1368
|
+
muteAgent?: boolean | null;
|
|
1369
|
+
voiceSettings?: {
|
|
1370
|
+
stability?: number;
|
|
1371
|
+
similarity_boost?: number;
|
|
1372
|
+
style?: number;
|
|
1373
|
+
use_speaker_boost?: boolean;
|
|
1374
|
+
} | null;
|
|
1324
1375
|
}): Promise<void>;
|
|
1325
1376
|
/**
|
|
1326
1377
|
* Mute or unmute the user's microphone
|
|
@@ -1338,6 +1389,24 @@ declare class Conversation extends EventEmitter<ConversationEvents> {
|
|
|
1338
1389
|
* Check if agent is muted
|
|
1339
1390
|
*/
|
|
1340
1391
|
isAgentMuted(): boolean;
|
|
1392
|
+
/**
|
|
1393
|
+
* Get the current call ID (available after connection)
|
|
1394
|
+
*/
|
|
1395
|
+
getCallId(): string | undefined;
|
|
1396
|
+
/**
|
|
1397
|
+
* Mute the call via API (POST /calls/{call_id}/mute)
|
|
1398
|
+
*/
|
|
1399
|
+
muteCall(): Promise<void>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Unmute the call via API (DELETE /calls/{call_id}/mute)
|
|
1402
|
+
*/
|
|
1403
|
+
unmuteCall(): Promise<void>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Get call mute status via API (GET /calls/{call_id}/mute)
|
|
1406
|
+
*/
|
|
1407
|
+
getCallMuteStatus(): Promise<{
|
|
1408
|
+
muted: boolean;
|
|
1409
|
+
}>;
|
|
1341
1410
|
/**
|
|
1342
1411
|
* Get conversation status
|
|
1343
1412
|
*/
|
|
@@ -1705,4 +1774,4 @@ declare function hasErrorCode(error: unknown, code: string): boolean;
|
|
|
1705
1774
|
*/
|
|
1706
1775
|
declare const VERSION = "0.0.2";
|
|
1707
1776
|
|
|
1708
|
-
export { AnganyError, AnganyVoice, type AuthError, type AuthEvents, AuthManager, type AuthOptions, type AuthState, type AuthStatus, AuthenticationError, type BackendAuthOptions, type ClientCredentials, ConfigurationError, Conversation, ConversationError, type ConversationOptions, type ConversationState, type ConversationStatus, ErrorCodes, EventEmitter, type FrontendAuthOptions, type LogLevel, MediaError, NetworkError, PermissionError, ResourceError, type ServiceAccountAuthOptions, type ServiceAccountCredentials, type SpeakOptions, type TokenSet, type TranscriptionEvent, type UserInfo, VERSION, ValidationError, type VoiceConfig, type VoiceResource, hasErrorCode, isAnganyError };
|
|
1777
|
+
export { AnganyError, AnganyVoice, type AuthError, type AuthEvents, AuthManager, type AuthOptions, type AuthState, type AuthStatus, AuthenticationError, type BackendAuthOptions, type ClientCredentials, ConfigurationError, Conversation, ConversationError, type ConversationOptions, type ConversationState, type ConversationStatus, type ConversationUrls, ErrorCodes, EventEmitter, type FrontendAuthOptions, type LogLevel, MediaError, NetworkError, PermissionError, ResourceError, type ServiceAccountAuthOptions, type ServiceAccountCredentials, type SpeakOptions, type TokenSet, type TranscriptionEvent, type UserInfo, VERSION, ValidationError, type VoiceConfig, type VoiceResource, hasErrorCode, isAnganyError };
|