@trillet-ai/web-sdk 1.3.4 → 1.3.5

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.
Files changed (4) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +184 -184
  3. package/dist/index.js +2 -2
  4. package/package.json +56 -56
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Trillet AI
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
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Trillet AI
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
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,184 +1,184 @@
1
- # Trillet AI Web Calls SDK
2
-
3
- The Trillet AI Web Calls SDK enables seamless integration of AI-powered voice and text interactions into web applications. This SDK provides a simple interface to connect with Trillet AI agents for real-time communication.
4
-
5
- ## Features
6
-
7
- - 🎙️ Real-time voice interactions with AI agents
8
- - 💬 Text-based conversations
9
- - 🔒 Secure authentication options
10
- - 📊 Audio visualization capabilities
11
- - 🎯 Event-driven architecture
12
- - 🔄 Real-time transcription
13
- - 🌐 Browser compatibility checks
14
-
15
- ## Installation
16
-
17
- ```bash
18
- npm install @trillet/webcalls-sdk
19
- # or
20
- yarn add @trillet/webcalls-sdk
21
- ```
22
-
23
- ## Quick Start
24
-
25
- ```typescript
26
- import { TrilletAgent } from '@trillet/webcalls-sdk';
27
-
28
- // Initialize the agent with API Key (Standard Method)
29
- const agent = new TrilletAgent({
30
- apiKey: 'your-api-key',
31
- workspaceId: 'your-workspace-id',
32
- agentId: 'your-agent-id',
33
-
34
- // Optional parameters
35
- variables: {
36
- customVar1: 'value1',
37
- customVar2: 'value2'
38
- },
39
- callbackUrl: 'https://your-callback-url.com'
40
- });
41
-
42
- // Start a regular call
43
- await agent.startCall();
44
-
45
- // Or start a public call
46
- await agent.startPublicCall();
47
-
48
- // Listen for events
49
- agent.on('connected', (details) => {
50
- console.log('Connected to call:', details);
51
- });
52
-
53
- agent.on('transcriptionReceived', (transcript) => {
54
- console.log('New transcript:', transcript);
55
- });
56
-
57
- // Control the call
58
- agent.toggleMicrophone(true); // Enable/disable microphone
59
- agent.endCall(); // End the call
60
- ```
61
-
62
- ## Authentication
63
-
64
- The SDK supports two authentication methods:
65
-
66
- 1. **API Key Authentication (Standard Method)**
67
- ```typescript
68
- const agent = new TrilletAgent({
69
- apiKey: 'your-api-key',
70
- workspaceId: 'your-workspace-id',
71
- agentId: 'your-agent-id'
72
- });
73
- ```
74
-
75
- 2. **Public Access**
76
- - For public-facing applications
77
- - Uses `startPublicCall()` method
78
- ```typescript
79
- const agent = new TrilletAgent({
80
- workspaceId: 'your-workspace-id',
81
- agentId: 'your-agent-id'
82
- });
83
- await agent.startPublicCall();
84
- ```
85
-
86
- ## Call Types
87
-
88
- The SDK supports two types of calls:
89
-
90
- 1. **Regular Call** - Using `startCall()`
91
- - Requires full authentication with API Key
92
- - Suitable for authenticated users
93
-
94
- 2. **Public Call** - Using `startPublicCall()`
95
- - Requires workspace ID and agent ID
96
- - Suitable for public-facing applications
97
- - No API key needed in client-side code
98
- - Example:
99
- ```typescript
100
- const agent = new TrilletAgent({
101
- workspaceId: 'your-workspace-id',
102
- agentId: 'your-agent-id' // Required for both public and regular calls
103
- });
104
- await agent.startPublicCall();
105
- ```
106
-
107
- ## Events
108
-
109
- The SDK emits various events that you can listen to:
110
-
111
- ```typescript
112
- agent.on('connected', (details) => {
113
- // Called when successfully connected to a call
114
- });
115
-
116
- agent.on('disconnected', () => {
117
- // Called when the call ends
118
- });
119
-
120
- agent.on('error', (error) => {
121
- // Called when an error occurs
122
- });
123
-
124
- agent.on('transcriptionReceived', (segments, participant) => {
125
- // Called when new transcription is available
126
- });
127
-
128
- agent.on('assistantStartedSpeaking', () => {
129
- // Called when the AI agent starts speaking
130
- });
131
-
132
- agent.on('assistantStoppedSpeaking', () => {
133
- // Called when the AI agent stops speaking
134
- });
135
-
136
- agent.on('audioData', (data) => {
137
- // Raw audio data for visualization
138
- });
139
- ```
140
-
141
- ## Voice Mode Features
142
-
143
- When using voice mode, the SDK provides additional audio-related features:
144
-
145
- ```typescript
146
- // Check if the assistant is currently speaking
147
- const isSpeaking = agent.isAssistantSpeaking;
148
-
149
- // Access transcripts
150
- const allTranscripts = agent.getTranscripts();
151
- const currentTranscript = agent.getCurrentTranscript();
152
- ```
153
-
154
- ## Requirements
155
-
156
- - Modern web browser with secure context (HTTPS or localhost)
157
- - WebRTC support
158
- - Microphone access (for voice mode)
159
-
160
- ## Browser Support
161
-
162
- The SDK is compatible with modern browsers that support WebRTC:
163
- - Chrome (recommended)
164
- - Firefox
165
- - Safari
166
- - Edge
167
-
168
- ## Error Handling
169
-
170
- The SDK includes comprehensive error handling:
171
-
172
- ```typescript
173
- agent.on('error', (error) => {
174
- console.error('Trillet SDK Error:', error);
175
- });
176
- ```
177
-
178
- ## License
179
-
180
- [License details here]
181
-
182
- ## Support
183
-
184
- For support, please contact [support contact information].
1
+ # Trillet AI Web Calls SDK
2
+
3
+ The Trillet AI Web Calls SDK enables seamless integration of AI-powered voice and text interactions into web applications. This SDK provides a simple interface to connect with Trillet AI agents for real-time communication.
4
+
5
+ ## Features
6
+
7
+ - 🎙️ Real-time voice interactions with AI agents
8
+ - 💬 Text-based conversations
9
+ - 🔒 Secure authentication options
10
+ - 📊 Audio visualization capabilities
11
+ - 🎯 Event-driven architecture
12
+ - 🔄 Real-time transcription
13
+ - 🌐 Browser compatibility checks
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @trillet-ai/web-sdk
19
+ # or
20
+ yarn add @trillet-ai/web-sdk
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { TrilletAgent } from '@trillet-ai/web-sdk';
27
+
28
+ // Initialize the agent with API Key (Standard Method)
29
+ const agent = new TrilletAgent({
30
+ apiKey: 'your-api-key',
31
+ workspaceId: 'your-workspace-id',
32
+ agentId: 'your-agent-id',
33
+
34
+ // Optional parameters
35
+ variables: {
36
+ customVar1: 'value1',
37
+ customVar2: 'value2'
38
+ },
39
+ callbackUrl: 'https://your-callback-url.com'
40
+ });
41
+
42
+ // Start a regular call
43
+ await agent.startCall();
44
+
45
+ // Or start a public call
46
+ await agent.startPublicCall();
47
+
48
+ // Listen for events
49
+ agent.on('connected', (details) => {
50
+ console.log('Connected to call:', details);
51
+ });
52
+
53
+ agent.on('transcriptionReceived', (transcript) => {
54
+ console.log('New transcript:', transcript);
55
+ });
56
+
57
+ // Control the call
58
+ agent.toggleMicrophone(true); // Enable/disable microphone
59
+ agent.endCall(); // End the call
60
+ ```
61
+
62
+ ## Authentication
63
+
64
+ The SDK supports two authentication methods:
65
+
66
+ 1. **API Key Authentication (Standard Method)**
67
+ ```typescript
68
+ const agent = new TrilletAgent({
69
+ apiKey: 'your-api-key',
70
+ workspaceId: 'your-workspace-id',
71
+ agentId: 'your-agent-id'
72
+ });
73
+ ```
74
+
75
+ 2. **Public Access**
76
+ - For public-facing applications
77
+ - Uses `startPublicCall()` method
78
+ ```typescript
79
+ const agent = new TrilletAgent({
80
+ workspaceId: 'your-workspace-id',
81
+ agentId: 'your-agent-id'
82
+ });
83
+ await agent.startPublicCall();
84
+ ```
85
+
86
+ ## Call Types
87
+
88
+ The SDK supports two types of calls:
89
+
90
+ 1. **Regular Call** - Using `startCall()`
91
+ - Requires full authentication with API Key
92
+ - Suitable for authenticated users
93
+
94
+ 2. **Public Call** - Using `startPublicCall()`
95
+ - Requires workspace ID and agent ID
96
+ - Suitable for public-facing applications
97
+ - No API key needed in client-side code
98
+ - Example:
99
+ ```typescript
100
+ const agent = new TrilletAgent({
101
+ workspaceId: 'your-workspace-id',
102
+ agentId: 'your-agent-id' // Required for both public and regular calls
103
+ });
104
+ await agent.startPublicCall();
105
+ ```
106
+
107
+ ## Events
108
+
109
+ The SDK emits various events that you can listen to:
110
+
111
+ ```typescript
112
+ agent.on('connected', (details) => {
113
+ // Called when successfully connected to a call
114
+ });
115
+
116
+ agent.on('disconnected', () => {
117
+ // Called when the call ends
118
+ });
119
+
120
+ agent.on('error', (error) => {
121
+ // Called when an error occurs
122
+ });
123
+
124
+ agent.on('transcriptionReceived', (segments, participant) => {
125
+ // Called when new transcription is available
126
+ });
127
+
128
+ agent.on('assistantStartedSpeaking', () => {
129
+ // Called when the AI agent starts speaking
130
+ });
131
+
132
+ agent.on('assistantStoppedSpeaking', () => {
133
+ // Called when the AI agent stops speaking
134
+ });
135
+
136
+ agent.on('audioData', (data) => {
137
+ // Raw audio data for visualization
138
+ });
139
+ ```
140
+
141
+ ## Voice Mode Features
142
+
143
+ When using voice mode, the SDK provides additional audio-related features:
144
+
145
+ ```typescript
146
+ // Check if the assistant is currently speaking
147
+ const isSpeaking = agent.isAssistantSpeaking;
148
+
149
+ // Access transcripts
150
+ const allTranscripts = agent.getTranscripts();
151
+ const currentTranscript = agent.getCurrentTranscript();
152
+ ```
153
+
154
+ ## Requirements
155
+
156
+ - Modern web browser with secure context (HTTPS or localhost)
157
+ - WebRTC support
158
+ - Microphone access (for voice mode)
159
+
160
+ ## Browser Support
161
+
162
+ The SDK is compatible with modern browsers that support WebRTC:
163
+ - Chrome (recommended)
164
+ - Firefox
165
+ - Safari
166
+ - Edge
167
+
168
+ ## Error Handling
169
+
170
+ The SDK includes comprehensive error handling:
171
+
172
+ ```typescript
173
+ agent.on('error', (error) => {
174
+ console.error('Trillet SDK Error:', error);
175
+ });
176
+ ```
177
+
178
+ ## License
179
+
180
+ [License details here]
181
+
182
+ ## Support
183
+
184
+ For support, please contact [support contact information].
package/dist/index.js CHANGED
@@ -94,10 +94,10 @@ export class TrilletAgent extends EventEmitter {
94
94
  headers: {
95
95
  "Content-Type": "application/json",
96
96
  Accept: "application/json",
97
- "X-API_KEY": this.config.apiKey,
97
+ "X-API-KEY": this.config.apiKey,
98
98
  },
99
99
  body: JSON.stringify({
100
- agentId: this.config.agentId,
100
+ call_agent_id: this.config.agentId,
101
101
  mode: this.config.mode,
102
102
  dynamic_variables: this.config.variables || {},
103
103
  callback_url: this.config.callbackUrl,
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "@trillet-ai/web-sdk",
3
- "version": "1.3.4",
4
- "description": "Trillet Web SDK for real-time audio communication with AI agents",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "module",
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "scripts": {
12
- "clean": "rimraf dist",
13
- "build": "npm run clean && tsc",
14
- "dev": "tsc --watch",
15
- "lint": "eslint src/**/*.{ts,tsx}",
16
- "prepare": "npm run build",
17
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
18
- },
19
- "peerDependencies": {
20
- "react": ">=16.8.0",
21
- "react-dom": ">=16.8.0"
22
- },
23
- "keywords": [
24
- "trillet",
25
- "ai",
26
- "voice",
27
- "audio",
28
- "sdk",
29
- "webrtc",
30
- "react"
31
- ],
32
- "author": "Trillet AI",
33
- "license": "MIT",
34
- "dependencies": {
35
- "eventemitter3": "^5.0.1",
36
- "livekit-client": "^2.8.1"
37
- },
38
- "devDependencies": {
39
- "@types/jest": "^29.5.12",
40
- "@types/node": "^20.11.0",
41
- "@types/react": "^18.2.0",
42
- "@types/react-dom": "^18.2.0",
43
- "@typescript-eslint/eslint-plugin": "^6.18.1",
44
- "@typescript-eslint/parser": "^6.18.1",
45
- "eslint": "^8.56.0",
46
- "jest": "^29.7.0",
47
- "rimraf": "^5.0.10",
48
- "ts-jest": "^29.1.2",
49
- "typescript": "^5.3.3"
50
- },
51
- "files": [
52
- "dist",
53
- "README.md",
54
- "LICENSE"
55
- ]
56
- }
1
+ {
2
+ "name": "@trillet-ai/web-sdk",
3
+ "version": "1.3.5",
4
+ "description": "Trillet Web SDK for real-time audio communication with AI agents",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "clean": "rimraf dist",
13
+ "build": "npm run clean && tsc",
14
+ "dev": "tsc --watch",
15
+ "lint": "eslint src/**/*.{ts,tsx}",
16
+ "prepare": "npm run build",
17
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
18
+ },
19
+ "peerDependencies": {
20
+ "react": ">=16.8.0",
21
+ "react-dom": ">=16.8.0"
22
+ },
23
+ "keywords": [
24
+ "trillet",
25
+ "ai",
26
+ "voice",
27
+ "audio",
28
+ "sdk",
29
+ "webrtc",
30
+ "react"
31
+ ],
32
+ "author": "Trillet AI",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "eventemitter3": "^5.0.1",
36
+ "livekit-client": "^2.8.1"
37
+ },
38
+ "devDependencies": {
39
+ "@types/jest": "^29.5.12",
40
+ "@types/node": "^20.11.0",
41
+ "@types/react": "^18.2.0",
42
+ "@types/react-dom": "^18.2.0",
43
+ "@typescript-eslint/eslint-plugin": "^6.18.1",
44
+ "@typescript-eslint/parser": "^6.18.1",
45
+ "eslint": "^8.56.0",
46
+ "jest": "^29.7.0",
47
+ "rimraf": "^5.0.10",
48
+ "ts-jest": "^29.1.2",
49
+ "typescript": "^5.3.3"
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "README.md",
54
+ "LICENSE"
55
+ ]
56
+ }