@trillet-ai/web-sdk 1.5.4 → 1.5.6
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 -1
- package/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,5 +42,5 @@ export declare class TrilletAgent extends EventEmitter {
|
|
|
42
42
|
* @param responseTimeout - Timeout in milliseconds (default: 30000)
|
|
43
43
|
*/
|
|
44
44
|
sendRpcMessage(method: string, payload: any, responseTimeout?: number): Promise<any>;
|
|
45
|
-
sendTextMessage(text: string): void
|
|
45
|
+
sendTextMessage(text: string): Promise<void>;
|
|
46
46
|
}
|
package/dist/index.js
CHANGED
|
@@ -276,7 +276,7 @@ export class TrilletAgent extends EventEmitter {
|
|
|
276
276
|
throw error;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
sendTextMessage(text) {
|
|
279
|
+
async sendTextMessage(text) {
|
|
280
280
|
if (this.config.mode !== 'text') {
|
|
281
281
|
console.warn('Cannot send text message in voice mode.');
|
|
282
282
|
return;
|
|
@@ -289,15 +289,14 @@ export class TrilletAgent extends EventEmitter {
|
|
|
289
289
|
// Add user message to transcripts immediately
|
|
290
290
|
this.transcriptManager.addMessage('user', text, room.localParticipant.identity);
|
|
291
291
|
this.emit('transcriptUpdate', this.getTranscripts());
|
|
292
|
-
// Send message
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
.
|
|
299
|
-
console.error('Failed to send text message via RPC:', error);
|
|
292
|
+
// Send the text message using LiveKit's sendText API with topic 'lk.chat'.
|
|
293
|
+
try {
|
|
294
|
+
await room.localParticipant.sendText(text, { topic: 'lk.chat' });
|
|
295
|
+
console.log('Text message sent to agent:', text);
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
console.error('Failed to send text message:', error);
|
|
300
299
|
this.emit('error', new Error(`Failed to send message: ${error instanceof Error ? error.message : String(error)}`));
|
|
301
|
-
}
|
|
300
|
+
}
|
|
302
301
|
}
|
|
303
302
|
}
|