Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Pull Request Type

🔮 Feature
🐛 BugFix
⚒️ Refactor
🧹 Chore
🔥 HotFix
🚀 Release
<leave only relevant line>

### Description
-

### Reference Links
- [Asana]() <add link inside brackets or delete line>
- [DataDog]() <add link inside brackets or delete line>
13 changes: 8 additions & 5 deletions .github/workflows/publish-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
dry_run:
description: 'Run in dry-run mode (no actual publishing)'
description: "Run in dry-run mode (no actual publishing)"
required: false
default: false
type: boolean
Expand Down Expand Up @@ -44,8 +44,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Install dependencies
run: |
Expand Down Expand Up @@ -236,15 +236,18 @@ jobs:
exit 0
fi

logger -l info -m "Installing dependencies to update yarn.lock"
yarn install

logger -l info -m "Creating new branch"
git checkout -b "chore/bump-sdk-version-${{ steps.version.outputs.version }}"

logger -l info -m "Configuring Git user"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

logger -l info -m "Adding and committing package.json"
git add package.json
logger -l info -m "Adding and committing package.json and yarn.lock"
git add package.json yarn.lock
git commit -m "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}"

logger -l info -m "Publishing branch to origin"
Expand Down
25 changes: 16 additions & 9 deletions src/services/streaming-manager/livekit-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function createLiveKitStreamingManager<T extends CreateSessionV2Opt
): Promise<StreamingManager<T> & { reconnect(): Promise<void> }> {
const log = createStreamingLogger(options.debug || false, 'LiveKitStreamingManager');

const { Room, RoomEvent, ConnectionState: LiveKitConnectionState } = await importLiveKit();
const { Room, RoomEvent, ConnectionState: LiveKitConnectionState, Track } = await importLiveKit();

const { callbacks, auth, baseURL, analytics, microphoneStream } = options;
let room: Room | null = null;
Expand Down Expand Up @@ -293,11 +293,11 @@ export async function createLiveKitStreamingManager<T extends CreateSessionV2Opt
topic?: string
): void {
const message = new TextDecoder().decode(payload);
log('Data received:', message);

try {
const data = JSON.parse(message);
const subject = topic || data.subject;
log('Data received:', { subject, data });

if (subject === StreamEvents.ChatAnswer) {
const eventName = ChatProgress.Answer;
Expand All @@ -311,14 +311,23 @@ export async function createLiveKitStreamingManager<T extends CreateSessionV2Opt
event: eventName,
...data,
});
} else if ([StreamEvents.StreamVideoCreated, StreamEvents.StreamVideoDone].includes(subject)) {
} else if (
[
StreamEvents.StreamVideoCreated,
StreamEvents.StreamVideoDone,
StreamEvents.StreamVideoError,
StreamEvents.StreamVideoRejected,
].includes(subject)
) {
currentActivityState =
subject === StreamEvents.StreamVideoCreated ? AgentActivityState.Talking : AgentActivityState.Idle;
callbacks.onAgentActivityStateChange?.(currentActivityState);

const role = data?.role || participant?.identity || 'datachannel';
const { role: providedRole, status: providedStatus, ...payload } = data;

const messageData: VideoMessageData = { [role]: data };
const role = providedRole ?? participant?.identity ?? 'datachannel';
const status = providedStatus ?? subject.split('/').pop() ?? 'unknown';
const messageData: VideoMessageData = { [role]: { ...payload, status } };

if (options.debug && data?.metadata?.sentiment) {
messageData.sentiment = {
Expand Down Expand Up @@ -363,10 +372,9 @@ export async function createLiveKitStreamingManager<T extends CreateSessionV2Opt
log('Track subscription failed:', { trackSid, participant, reason });
}

async function findPublishedMicrophoneTrack(audioTrack: MediaStreamTrack): Promise<LocalTrackPublication | null> {
function findPublishedMicrophoneTrack(audioTrack: MediaStreamTrack): LocalTrackPublication | null {
if (!room) return null;

const { Track } = await importLiveKit();
const publishedTracks = room.localParticipant.audioTrackPublications;

if (publishedTracks) {
Expand Down Expand Up @@ -409,9 +417,8 @@ export async function createLiveKitStreamingManager<T extends CreateSessionV2Opt
}

const audioTrack = audioTracks[0];
const { Track } = await importLiveKit();

const existingPublication = await findPublishedMicrophoneTrack(audioTrack);
const existingPublication = findPublishedMicrophoneTrack(audioTrack);
if (existingPublication) {
log('Microphone track is already published, skipping', {
trackId: audioTrack.id,
Expand Down
Loading