From ee7bb09b4dc734bbae2f7b09a898885726198599 Mon Sep 17 00:00:00 2001 From: Arik Sfaradi Date: Sun, 14 Dec 2025 17:22:36 +0200 Subject: [PATCH 1/3] Bugfix/livekit (#237) * pass debug configuration from demo app * Fix freeze issue - livekit get tracks that need to be attached to video elem - since we pass the MediaStream - create hidden element and attach it there - keeps the track active * fixing bug that sometimes the streaming manager is undefined * in livekit there is no need to use ws - all data is from the dataChannel * use livekit chat for streams v2 * sendTextMessage is in livekit usage * handle activity state changes * use preppareConnection to speed up connection time * use sendTextMessage to publish messages topic: 'lk.chat' - indicates that the streamingOrchestrator use built in AgentSession * fix init issues * monitor faulure events * use sendTextMessage * indicate that streaming started * refactoring * resolve conflicts * cursor review * review fix - redundant * review - unused * review - add doc that indicates its only v2 * review --- demo/app.tsx | 11 +- demo/environment.ts | 1 + demo/hooks/useAgentManager.ts | 3 + .../agent-manager/connect-to-manager.ts | 14 +- src/services/agent-manager/index.ts | 79 +++--- src/services/streaming-manager/common.ts | 7 + .../streaming-manager/livekit-manager.ts | 259 +++++++++++++----- 7 files changed, 268 insertions(+), 106 deletions(-) diff --git a/demo/app.tsx b/demo/app.tsx index 5df62f90..6aa04403 100644 --- a/demo/app.tsx +++ b/demo/app.tsx @@ -2,7 +2,7 @@ import { ChatMode, ConnectionState } from '@sdk/types'; import { useEffect, useRef, useState } from 'preact/hooks'; import './app.css'; -import { agentId, clientKey, didApiUrl, didSocketApiUrl } from './environment'; +import { agentId, clientKey, debug, didApiUrl, didSocketApiUrl } from './environment'; import { useAgentManager } from './hooks/useAgentManager'; export function App() { @@ -19,6 +19,7 @@ export function App() { const { srcObject, connectionState, messages, isSpeaking, connect, disconnect, speak, chat, interrupt } = useAgentManager({ + debug, agentId, baseURL: didApiUrl, wsURL: didSocketApiUrl, @@ -64,10 +65,10 @@ export function App() { {connectionState === ConnectionState.Connected ? 'Send' : connectionState === ConnectionState.Connecting - ? 'Connecting...' - : connectionState === ConnectionState.Fail - ? 'Failed, Try Again' - : 'Connect'} + ? 'Connecting...' + : connectionState === ConnectionState.Fail + ? 'Failed, Try Again' + : 'Connect'}