ug-js-sdk 3.0.46
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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/ug-core/conversation-manager/ConversationCommands.d.ts +26 -0
- package/dist/ug-core/conversation-manager/ConversationCommands.js +39 -0
- package/dist/ug-core/conversation-manager/ConversationCommands.js.map +1 -0
- package/dist/ug-core/conversation-manager/ConversationManager.d.ts +596 -0
- package/dist/ug-core/conversation-manager/ConversationManager.js +1144 -0
- package/dist/ug-core/conversation-manager/ConversationManager.js.map +1 -0
- package/dist/ug-core/conversation-manager/ErrorRetryHandler.d.ts +37 -0
- package/dist/ug-core/conversation-manager/ErrorRetryHandler.js +82 -0
- package/dist/ug-core/conversation-manager/ErrorRetryHandler.js.map +1 -0
- package/dist/ug-core/conversation-manager/index.d.ts +2 -0
- package/dist/ug-core/conversation-manager/index.js +3 -0
- package/dist/ug-core/conversation-manager/index.js.map +1 -0
- package/dist/ug-core/conversation-manager/types.d.ts +203 -0
- package/dist/ug-core/conversation-manager/types.js +2 -0
- package/dist/ug-core/conversation-manager/types.js.map +1 -0
- package/dist/ug-core/core/EventEmitter.d.ts +11 -0
- package/dist/ug-core/core/EventEmitter.js +64 -0
- package/dist/ug-core/core/EventEmitter.js.map +1 -0
- package/dist/ug-core/core/Logger.d.ts +27 -0
- package/dist/ug-core/core/Logger.js +86 -0
- package/dist/ug-core/core/Logger.js.map +1 -0
- package/dist/ug-core/core/localStorage.d.ts +16 -0
- package/dist/ug-core/core/localStorage.js +54 -0
- package/dist/ug-core/core/localStorage.js.map +1 -0
- package/dist/ug-core/index.d.ts +29 -0
- package/dist/ug-core/index.js +25 -0
- package/dist/ug-core/index.js.map +1 -0
- package/dist/ug-core/network/ConversationNetwork.d.ts +68 -0
- package/dist/ug-core/network/ConversationNetwork.js +327 -0
- package/dist/ug-core/network/ConversationNetwork.js.map +1 -0
- package/dist/ug-core/network/WebSocketConnection.d.ts +12 -0
- package/dist/ug-core/network/WebSocketConnection.js +49 -0
- package/dist/ug-core/network/WebSocketConnection.js.map +1 -0
- package/dist/ug-core/network/api.d.ts +69 -0
- package/dist/ug-core/network/api.js +173 -0
- package/dist/ug-core/network/api.js.map +1 -0
- package/dist/ug-core/network/types.d.ts +34 -0
- package/dist/ug-core/network/types.js +7 -0
- package/dist/ug-core/network/types.js.map +1 -0
- package/dist/ug-core/playback-manager/PlaybackManager.d.ts +56 -0
- package/dist/ug-core/playback-manager/PlaybackManager.js +235 -0
- package/dist/ug-core/playback-manager/PlaybackManager.js.map +1 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayer.d.ts +77 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayer.js +594 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayer.js.map +1 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayerTiming.d.ts +27 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayerTiming.js +84 -0
- package/dist/ug-core/playback-manager/audio-player/AudioPlayerTiming.js.map +1 -0
- package/dist/ug-core/playback-manager/audio-player/MP3FrameExtractor.d.ts +20 -0
- package/dist/ug-core/playback-manager/audio-player/MP3FrameExtractor.js +132 -0
- package/dist/ug-core/playback-manager/audio-player/MP3FrameExtractor.js.map +1 -0
- package/dist/ug-core/playback-manager/audio-player/utils.d.ts +2 -0
- package/dist/ug-core/playback-manager/audio-player/utils.js +17 -0
- package/dist/ug-core/playback-manager/audio-player/utils.js.map +1 -0
- package/dist/ug-core/playback-manager/avatar-manager/AvatarManager.d.ts +25 -0
- package/dist/ug-core/playback-manager/avatar-manager/AvatarManager.js +68 -0
- package/dist/ug-core/playback-manager/avatar-manager/AvatarManager.js.map +1 -0
- package/dist/ug-core/playback-manager/index.d.ts +1 -0
- package/dist/ug-core/playback-manager/index.js +2 -0
- package/dist/ug-core/playback-manager/index.js.map +1 -0
- package/dist/ug-core/playback-manager/subtitle-manager/SubtitleManager.d.ts +37 -0
- package/dist/ug-core/playback-manager/subtitle-manager/SubtitleManager.js +298 -0
- package/dist/ug-core/playback-manager/subtitle-manager/SubtitleManager.js.map +1 -0
- package/dist/ug-core/playback-manager/types.d.ts +106 -0
- package/dist/ug-core/playback-manager/types.js +20 -0
- package/dist/ug-core/playback-manager/types.js.map +1 -0
- package/dist/ug-core/playback-manager/viseme-scheduler/VisemeScheduler.d.ts +11 -0
- package/dist/ug-core/playback-manager/viseme-scheduler/VisemeScheduler.js +31 -0
- package/dist/ug-core/playback-manager/viseme-scheduler/VisemeScheduler.js.map +1 -0
- package/dist/ug-core/types/index.d.ts +780 -0
- package/dist/ug-core/types/index.js +15 -0
- package/dist/ug-core/types/index.js.map +1 -0
- package/dist/ug-core/user-input-manager/AudioRecorder.d.ts +55 -0
- package/dist/ug-core/user-input-manager/AudioRecorder.js +349 -0
- package/dist/ug-core/user-input-manager/AudioRecorder.js.map +1 -0
- package/dist/ug-core/user-input-manager/MediaRecorderFallback.d.ts +15 -0
- package/dist/ug-core/user-input-manager/MediaRecorderFallback.js +46 -0
- package/dist/ug-core/user-input-manager/MediaRecorderFallback.js.map +1 -0
- package/dist/ug-core/user-input-manager/UserInputManager.d.ts +61 -0
- package/dist/ug-core/user-input-manager/UserInputManager.js +332 -0
- package/dist/ug-core/user-input-manager/UserInputManager.js.map +1 -0
- package/dist/ug-core/user-input-manager/VADManager.d.ts +26 -0
- package/dist/ug-core/user-input-manager/VADManager.js +129 -0
- package/dist/ug-core/user-input-manager/VADManager.js.map +1 -0
- package/dist/ug-core/user-input-manager/index.d.ts +4 -0
- package/dist/ug-core/user-input-manager/index.js +4 -0
- package/dist/ug-core/user-input-manager/index.js.map +1 -0
- package/dist/ug-core/user-input-manager/types.d.ts +41 -0
- package/dist/ug-core/user-input-manager/types.js +16 -0
- package/dist/ug-core/user-input-manager/types.js.map +1 -0
- package/dist/ug-js-sdk.mjs +184 -0
- package/dist/ug-js-sdk.mjs.LICENSE.txt +5 -0
- package/dist/ug-js-sdk.mjs.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 UG labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# UG JS SDK
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
JavaScript SDK for building conversational AI experiences with voice, text, avatars, and real-time interactions.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install ug-js-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { ConversationManager } from 'ug-js-sdk'
|
|
19
|
+
|
|
20
|
+
const conversation = new ConversationManager({
|
|
21
|
+
apiUrl: 'wss://pug.uglabs.app',
|
|
22
|
+
apiKey: 'your-api-key',
|
|
23
|
+
federatedId: 'user-123',
|
|
24
|
+
prompt: 'You are a friendly assistant.',
|
|
25
|
+
hooks: {
|
|
26
|
+
onStateChange: (state) => console.log('State:', state),
|
|
27
|
+
onTextMessage: (event) => console.log('Assistant:', event.text),
|
|
28
|
+
onError: (error) => console.error('Error:', error.message),
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Start the conversation
|
|
33
|
+
await conversation.start()
|
|
34
|
+
|
|
35
|
+
// Send text input
|
|
36
|
+
await conversation.sendText('Hello!')
|
|
37
|
+
|
|
38
|
+
// Or enable voice input
|
|
39
|
+
await conversation.startListening()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Voice Input/Output** - Real-time speech-to-text and text-to-speech
|
|
45
|
+
- **Text Chat** - Send and receive text messages
|
|
46
|
+
- **Avatar Support** - Lip-sync animations with viseme data
|
|
47
|
+
- **Subtitles** - Real-time captions with word highlighting
|
|
48
|
+
- **Utilities** - Built-in classifiers and extractors for AI operations
|
|
49
|
+
- **Safety Policies** - Content filtering and moderation
|
|
50
|
+
- **Image Generation** - Generate images via Bria or Replicate
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const config: ConversationConfig = {
|
|
56
|
+
apiUrl: 'wss://pug.uglabs.app',
|
|
57
|
+
apiKey: 'your-api-key',
|
|
58
|
+
federatedId: 'user-id',
|
|
59
|
+
prompt: 'Your system prompt here',
|
|
60
|
+
|
|
61
|
+
// Optional: Configure capabilities
|
|
62
|
+
capabilities: {
|
|
63
|
+
audio: true,
|
|
64
|
+
subtitles: true,
|
|
65
|
+
viseme: false,
|
|
66
|
+
avatar: false,
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Optional: Voice settings
|
|
70
|
+
voiceProfile: {
|
|
71
|
+
voice_id: 'voice-id',
|
|
72
|
+
speed: 1.0,
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
hooks: {
|
|
76
|
+
onStateChange: (state) => { /* handle state */ },
|
|
77
|
+
onTextMessage: (event) => { /* handle text */ },
|
|
78
|
+
onSubtitleChange: (subtitle) => { /* handle subtitles */ },
|
|
79
|
+
onError: (error) => { /* handle errors */ },
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Conversation States
|
|
85
|
+
|
|
86
|
+
The SDK manages the following states:
|
|
87
|
+
|
|
88
|
+
| State | Description |
|
|
89
|
+
|-------|-------------|
|
|
90
|
+
| `uninitialized` | Before connection |
|
|
91
|
+
| `initializing` | Connecting to server |
|
|
92
|
+
| `idle` | Ready for interaction |
|
|
93
|
+
| `listening` | Listening for voice input |
|
|
94
|
+
| `userSpeaking` | User is speaking |
|
|
95
|
+
| `waiting` | Processing input |
|
|
96
|
+
| `playing` | Playing audio response |
|
|
97
|
+
|
|
98
|
+
## Documentation
|
|
99
|
+
|
|
100
|
+
For full documentation, API reference, and examples visit:
|
|
101
|
+
|
|
102
|
+
**[docs.uglabs.io/sdk/js](https://docs.uglabs.io/sdk/js)**
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ug-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains conversation command strings that can be customized externally.
|
|
3
|
+
* These commands are sent to the conversation system to control conversation flow.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConversationCommands {
|
|
6
|
+
static readonly DEFAULT_START_COMMAND = "[start conversation]";
|
|
7
|
+
static readonly DEFAULT_PAUSE_RESUME_COMMAND = "[resume after short pause]";
|
|
8
|
+
static readonly DEFAULT_LONG_PAUSE_RESUME_COMMAND = "[resume after long break]";
|
|
9
|
+
static readonly DEFAULT_ERROR_RESUME_COMMAND = "[resume after error]";
|
|
10
|
+
startCommand: string;
|
|
11
|
+
pauseResumeCommand: string;
|
|
12
|
+
longPauseResumeCommand: string;
|
|
13
|
+
errorResumeCommand: string;
|
|
14
|
+
/**
|
|
15
|
+
* Sets all command values at once
|
|
16
|
+
* @param startCommand Command to start conversation
|
|
17
|
+
* @param pauseResumeCommand Command to resume conversation after a short pause
|
|
18
|
+
* @param longPauseResumeCommand Command to resume after a long break
|
|
19
|
+
* @param errorResumeCommand Command to resume after error
|
|
20
|
+
*/
|
|
21
|
+
set(startCommand?: string, pauseResumeCommand?: string, longPauseResumeCommand?: string, errorResumeCommand?: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Resets all command values to their defaults
|
|
24
|
+
*/
|
|
25
|
+
setDefault(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains conversation command strings that can be customized externally.
|
|
3
|
+
* These commands are sent to the conversation system to control conversation flow.
|
|
4
|
+
*/
|
|
5
|
+
export class ConversationCommands {
|
|
6
|
+
// Default command constants
|
|
7
|
+
static DEFAULT_START_COMMAND = '[start conversation]';
|
|
8
|
+
static DEFAULT_PAUSE_RESUME_COMMAND = '[resume after short pause]';
|
|
9
|
+
static DEFAULT_LONG_PAUSE_RESUME_COMMAND = '[resume after long break]';
|
|
10
|
+
static DEFAULT_ERROR_RESUME_COMMAND = '[resume after error]';
|
|
11
|
+
startCommand = ConversationCommands.DEFAULT_START_COMMAND;
|
|
12
|
+
pauseResumeCommand = ConversationCommands.DEFAULT_PAUSE_RESUME_COMMAND;
|
|
13
|
+
longPauseResumeCommand = ConversationCommands.DEFAULT_LONG_PAUSE_RESUME_COMMAND;
|
|
14
|
+
errorResumeCommand = ConversationCommands.DEFAULT_ERROR_RESUME_COMMAND;
|
|
15
|
+
/**
|
|
16
|
+
* Sets all command values at once
|
|
17
|
+
* @param startCommand Command to start conversation
|
|
18
|
+
* @param pauseResumeCommand Command to resume conversation after a short pause
|
|
19
|
+
* @param longPauseResumeCommand Command to resume after a long break
|
|
20
|
+
* @param errorResumeCommand Command to resume after error
|
|
21
|
+
*/
|
|
22
|
+
set(startCommand, pauseResumeCommand, longPauseResumeCommand, errorResumeCommand) {
|
|
23
|
+
this.startCommand = startCommand ?? ConversationCommands.DEFAULT_START_COMMAND;
|
|
24
|
+
this.pauseResumeCommand = pauseResumeCommand ?? ConversationCommands.DEFAULT_PAUSE_RESUME_COMMAND;
|
|
25
|
+
this.longPauseResumeCommand =
|
|
26
|
+
longPauseResumeCommand ?? ConversationCommands.DEFAULT_LONG_PAUSE_RESUME_COMMAND;
|
|
27
|
+
this.errorResumeCommand = errorResumeCommand ?? ConversationCommands.DEFAULT_ERROR_RESUME_COMMAND;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resets all command values to their defaults
|
|
31
|
+
*/
|
|
32
|
+
setDefault() {
|
|
33
|
+
this.startCommand = ConversationCommands.DEFAULT_START_COMMAND;
|
|
34
|
+
this.pauseResumeCommand = ConversationCommands.DEFAULT_PAUSE_RESUME_COMMAND;
|
|
35
|
+
this.longPauseResumeCommand = ConversationCommands.DEFAULT_LONG_PAUSE_RESUME_COMMAND;
|
|
36
|
+
this.errorResumeCommand = ConversationCommands.DEFAULT_ERROR_RESUME_COMMAND;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ConversationCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationCommands.js","sourceRoot":"","sources":["../../../src/ug-core/conversation-manager/ConversationCommands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAC/B,4BAA4B;IACrB,MAAM,CAAU,qBAAqB,GAAG,sBAAsB,CAAA;IAC9D,MAAM,CAAU,4BAA4B,GAAG,4BAA4B,CAAA;IAC3E,MAAM,CAAU,iCAAiC,GAAG,2BAA2B,CAAA;IAC/E,MAAM,CAAU,4BAA4B,GAAG,sBAAsB,CAAA;IAErE,YAAY,GAAW,oBAAoB,CAAC,qBAAqB,CAAA;IACjE,kBAAkB,GAAW,oBAAoB,CAAC,4BAA4B,CAAA;IAC9E,sBAAsB,GAAW,oBAAoB,CAAC,iCAAiC,CAAA;IACvF,kBAAkB,GAAW,oBAAoB,CAAC,4BAA4B,CAAA;IAErF;;;;;;OAMG;IACI,GAAG,CACR,YAAqB,EACrB,kBAA2B,EAC3B,sBAA+B,EAC/B,kBAA2B;QAE3B,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,oBAAoB,CAAC,qBAAqB,CAAA;QAC9E,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,oBAAoB,CAAC,4BAA4B,CAAA;QACjG,IAAI,CAAC,sBAAsB;YACzB,sBAAsB,IAAI,oBAAoB,CAAC,iCAAiC,CAAA;QAClF,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,oBAAoB,CAAC,4BAA4B,CAAA;IACnG,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAC,qBAAqB,CAAA;QAC9D,IAAI,CAAC,kBAAkB,GAAG,oBAAoB,CAAC,4BAA4B,CAAA;QAC3E,IAAI,CAAC,sBAAsB,GAAG,oBAAoB,CAAC,iCAAiC,CAAA;QACpF,IAAI,CAAC,kBAAkB,GAAG,oBAAoB,CAAC,4BAA4B,CAAA;IAC7E,CAAC"}
|