@trillet-ai/web-sdk 1.1.2 → 1.1.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.d.ts +1 -0
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "eventemitter3";
|
|
2
2
|
import { RemoteAudioTrack, Room, RoomEvent, Track, createAudioAnalyser, } from "livekit-client";
|
|
3
3
|
const TRILLET_API_URL = "https://api.trillet.ai/v1/api/web-call";
|
|
4
|
-
const TRILLET_WS_URL = "wss://trilletai-ek0j3un1.livekit.cloud";
|
|
5
4
|
const decoder = new TextDecoder();
|
|
6
5
|
// Browser compatibility check
|
|
7
6
|
const isBrowser = typeof window !== 'undefined';
|
|
@@ -50,8 +49,6 @@ export class TrilletAgent extends EventEmitter {
|
|
|
50
49
|
'x-workspace-id': this.config.workspaceId,
|
|
51
50
|
'x-api-key': this.config.apiKey
|
|
52
51
|
},
|
|
53
|
-
mode: 'cors',
|
|
54
|
-
credentials: 'same-origin',
|
|
55
52
|
body: JSON.stringify({
|
|
56
53
|
call_agent_id: this.config.agentId,
|
|
57
54
|
dynamic_variables: this.config.variables || {}
|
|
@@ -75,6 +72,7 @@ export class TrilletAgent extends EventEmitter {
|
|
|
75
72
|
// 2. Initialize call with LiveKit token
|
|
76
73
|
await this.sdk.initializeCall({
|
|
77
74
|
token: data.token,
|
|
75
|
+
wsUrl: data.connection.url,
|
|
78
76
|
audioSettings: {
|
|
79
77
|
sampleRate: 48000
|
|
80
78
|
},
|
|
@@ -87,7 +85,7 @@ export class TrilletAgent extends EventEmitter {
|
|
|
87
85
|
}
|
|
88
86
|
catch (error) {
|
|
89
87
|
console.error('Trillet SDK Error:', error);
|
|
90
|
-
this.emit('error', error);
|
|
88
|
+
this.emit('error', error instanceof Error ? error : new Error(String(error)));
|
|
91
89
|
throw error;
|
|
92
90
|
}
|
|
93
91
|
}
|
|
@@ -126,16 +124,18 @@ class TrilletWebSDK extends EventEmitter {
|
|
|
126
124
|
},
|
|
127
125
|
});
|
|
128
126
|
this.setupEventHandlers(config);
|
|
129
|
-
await this.room.connect(
|
|
127
|
+
await this.room.connect(config.wsUrl, config.token);
|
|
130
128
|
console.log("Connected to Trillet room:", this.room.name);
|
|
131
129
|
this.room.localParticipant.setMicrophoneEnabled(true);
|
|
132
130
|
this.isConnected = true;
|
|
133
131
|
this.emit("connected");
|
|
134
132
|
}
|
|
135
133
|
catch (error) {
|
|
136
|
-
|
|
134
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to initialize call';
|
|
135
|
+
this.emit("error", errorMessage);
|
|
137
136
|
console.error("Call initialization failed:", error);
|
|
138
137
|
this.endCall();
|
|
138
|
+
throw error; // Re-throw to let TrilletAgent handle it
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
async enableAudioPlayback() {
|