From 9333ba919dda7a36bccddb3506f845173fba33d7 Mon Sep 17 00:00:00 2001 From: D-ID <104424511+d-id-api@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:08:00 +0300 Subject: [PATCH 1/5] chore: sync version 1.1.7 from prod (#189) * chore: sync version 1.1.7 from prod [skip ci] * fix identation --------- Co-authored-by: github-actions[bot] Co-authored-by: Dor Eitan --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28d6627e..a3803e6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@d-id/client-sdk", "private": false, - "version": "1.1.6", + "version": "1.1.7", "type": "module", "description": "d-id client sdk", "repository": { From de531a1d4f5791e62cb22b63adde036442933228 Mon Sep 17 00:00:00 2001 From: dor-eitan <164745144+dor-eitan@users.noreply.github.com> Date: Tue, 12 Aug 2025 15:31:38 +0300 Subject: [PATCH 2/5] bugfix: parallel chat and stream init (#191) --- src/api/streams/index.ts | 3 +- .../streams/{clipStream.ts => streamApi.ts} | 17 ++--- src/api/streams/talkStream.ts | 63 ------------------- .../agent-manager/connect-to-manager.ts | 26 ++++---- src/services/streaming-manager/index.ts | 13 ++-- src/types/stream/stream.ts | 3 - 6 files changed, 25 insertions(+), 100 deletions(-) rename src/api/streams/{clipStream.ts => streamApi.ts} (76%) delete mode 100644 src/api/streams/talkStream.ts diff --git a/src/api/streams/index.ts b/src/api/streams/index.ts index 10dae593..c86188d1 100644 --- a/src/api/streams/index.ts +++ b/src/api/streams/index.ts @@ -1,2 +1 @@ -export * from './clipStream' -export * from './talkStream' \ No newline at end of file +export * from './streamApi'; diff --git a/src/api/streams/clipStream.ts b/src/api/streams/streamApi.ts similarity index 76% rename from src/api/streams/clipStream.ts rename to src/api/streams/streamApi.ts index 5a1ae93f..d4fd971e 100644 --- a/src/api/streams/clipStream.ts +++ b/src/api/streams/streamApi.ts @@ -1,16 +1,17 @@ import { Auth, - ClipStreamOptions, + CreateStreamOptions, ICreateStreamRequestResponse, IceCandidate, RtcApi, SendClipStreamPayload, SendStreamPayloadResponse, + SendTalkStreamPayload, Status, } from '$/types/index'; import { createClient } from '../apiClient'; -export function createClipApi( +export function createStreamApi( auth: Auth, host: string, agentId: string, @@ -19,14 +20,8 @@ export function createClipApi( const client = createClient(auth, `${host}/agents/${agentId}`, onError); return { - createStream(options: ClipStreamOptions) { - return client.post('/streams', { - output_resolution: options.output_resolution, - compatibility_mode: options.compatibility_mode, - stream_warmup: options.stream_warmup, - session_timeout: options.session_timeout, - fluent: options.fluent, - }); + createStream(options: CreateStreamOptions) { + return client.post('/streams', options); }, startConnection(streamId: string, answer: RTCSessionDescriptionInit, sessionId?: string) { return client.post(`/streams/${streamId}/sdp`, { @@ -40,7 +35,7 @@ export function createClipApi( ...candidate, }); }, - sendStreamRequest(streamId: string, sessionId: string, payload: SendClipStreamPayload) { + sendStreamRequest(streamId: string, sessionId: string, payload: SendClipStreamPayload | SendTalkStreamPayload) { return client.post(`/streams/${streamId}`, { session_id: sessionId, ...payload, diff --git a/src/api/streams/talkStream.ts b/src/api/streams/talkStream.ts deleted file mode 100644 index b6596f72..00000000 --- a/src/api/streams/talkStream.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { - Auth, - ICreateStreamRequestResponse, - IceCandidate, - RtcApi, - SendStreamPayloadResponse, - SendTalkStreamPayload, - Status, - TalkStreamOptions, -} from '$/types/index'; -import { createClient } from '../apiClient'; - -export function createTalkApi( - auth: Auth, - host: string, - agentId: string, - onError?: (error: Error, errorData: object) => void -): RtcApi { - const client = createClient(auth, `${host}/agents/${agentId}`, onError); - - return { - createStream(streamOptions: TalkStreamOptions, options?: RequestInit) { - return client.post( - '/streams', - { - driver_url: streamOptions.driver_url, - face: streamOptions.face, - config: streamOptions.config, - output_resolution: streamOptions.output_resolution, - compatibility_mode: streamOptions.compatibility_mode, - stream_warmup: streamOptions.stream_warmup, - session_timeout: streamOptions.session_timeout, - fluent: streamOptions.fluent, - }, - options - ); - }, - startConnection( - streamId: string, - answer: RTCSessionDescriptionInit, - sessionId?: string, - options?: RequestInit - ) { - return client.post(`/streams/${streamId}/sdp`, { session_id: sessionId, answer }, options); - }, - addIceCandidate(streamId: string, candidate: IceCandidate, sessionId: string, options?: RequestInit) { - return client.post(`/streams/${streamId}/ice`, { session_id: sessionId, ...candidate }, options); - }, - sendStreamRequest(streamId: string, sessionId: string, payload: SendTalkStreamPayload, options?: RequestInit) { - return client.post( - `/streams/${streamId}`, - { - session_id: sessionId, - ...payload, - }, - options - ); - }, - close(streamId: string, sessionId: string, options?: RequestInit) { - return client.delete(`/streams/${streamId}`, { session_id: sessionId }, options); - }, - }; -} diff --git a/src/services/agent-manager/connect-to-manager.ts b/src/services/agent-manager/connect-to-manager.ts index f7a7fd04..24fc9d49 100644 --- a/src/services/agent-manager/connect-to-manager.ts +++ b/src/services/agent-manager/connect-to-manager.ts @@ -12,17 +12,15 @@ import { StreamEvents, StreamType, StreamingState, - mapVideoType, } from '$/types'; import { Analytics } from '../analytics/mixpanel'; import { interruptTimestampTracker, latencyTimestampTracker } from '../analytics/timestamp-tracker'; import { createChat } from '../chat'; -function getAgentStreamArgs(agent: Agent, options?: AgentManagerOptions): CreateStreamOptions { +function getAgentStreamArgs(options?: AgentManagerOptions): CreateStreamOptions { const { streamOptions } = options ?? {}; return { - videoType: mapVideoType(agent.presenter.type), output_resolution: streamOptions?.outputResolution, session_timeout: streamOptions?.sessionTimeout, stream_warmup: streamOptions?.streamWarmup, @@ -142,7 +140,7 @@ function connectToManager( return new Promise(async (resolve, reject) => { try { - const streamingManager = await createStreamingManager(agent.id, getAgentStreamArgs(agent, options), { + const streamingManager = await createStreamingManager(agent.id, getAgentStreamArgs(options), { ...options, analytics, callbacks: { @@ -196,27 +194,25 @@ export async function initializeStreamAndChat( analytics: Analytics, chat?: Chat ): Promise<{ chat?: Chat; streamingManager?: StreamingManager }> { - const { chat: newChat, chatMode } = await createChat( - agent, - agentsApi, - analytics, - options.mode, - options.persistentChat, - chat - ); + const createChatPromise = createChat(agent, agentsApi, analytics, options.mode, options.persistentChat, chat); + const connectToManagerPromise = connectToManager(agent, options, analytics); + + const [chatResult, streamingManager] = await Promise.all([createChatPromise, connectToManagerPromise]); + + const { chat: newChat, chatMode } = chatResult; if (chatMode && chatMode !== options.mode) { options.mode = chatMode; options.callbacks.onModeChange?.(chatMode); - if (chatMode === ChatMode.TextOnly) { + if (chatMode !== ChatMode.Functional) { options.callbacks.onError?.(new ChatModeDowngraded(chatMode)); + streamingManager?.disconnect(); + return { chat: newChat }; } } - const streamingManager = await connectToManager(agent, options, analytics); - return { chat: newChat, streamingManager }; } diff --git a/src/services/streaming-manager/index.ts b/src/services/streaming-manager/index.ts index 478a3769..881ca1e4 100644 --- a/src/services/streaming-manager/index.ts +++ b/src/services/streaming-manager/index.ts @@ -1,4 +1,4 @@ -import { createClipApi, createTalkApi } from '$/api/streams'; +import { createStreamApi } from '$/api/streams'; import { didApiUrl } from '$/config/environment'; import { AgentActivityState, @@ -9,7 +9,6 @@ import { StreamType, StreamingManagerOptions, StreamingState, - VideoType, } from '$/types/index'; import { pollStats } from './stats/poll'; import { VideoRTCStatsReport } from './stats/report'; @@ -142,10 +141,12 @@ export async function createStreamingManager( let dataChannelSignal: StreamingState = StreamingState.Stop; let statsSignal: StreamingState = StreamingState.Stop; - const { startConnection, sendStreamRequest, close, createStream, addIceCandidate } = - agent.videoType === VideoType.Clip - ? createClipApi(auth, baseURL, agentId, callbacks.onError) - : createTalkApi(auth, baseURL, agentId, callbacks.onError); + const { startConnection, sendStreamRequest, close, createStream, addIceCandidate } = createStreamApi( + auth, + baseURL, + agentId, + callbacks.onError + ); const { id: streamIdFromServer, diff --git a/src/types/stream/stream.ts b/src/types/stream/stream.ts index e135f13b..d32b0f6d 100644 --- a/src/types/stream/stream.ts +++ b/src/types/stream/stream.ts @@ -1,7 +1,6 @@ import { Analytics } from '$/services/analytics/mixpanel'; import { VideoRTCStatsReport } from '$/services/streaming-manager/stats/report'; import { Auth } from '../auth'; -import { VideoType } from '../entities'; import { CreateClipStreamRequest, CreateTalkStreamRequest, SendClipStreamPayload, SendTalkStreamPayload } from './api'; import { ICreateStreamRequestResponse, IceCandidate, SendStreamPayloadResponse, Status } from './rtc'; @@ -67,12 +66,10 @@ export interface ManagerCallbacks { export type ManagerCallbackKeys = keyof ManagerCallbacks; export interface TalkStreamOptions extends CreateTalkStreamRequest { - videoType: VideoType.Talk; fluent?: boolean; } export interface ClipStreamOptions extends CreateClipStreamRequest { - videoType: VideoType.Clip; fluent?: boolean; } From 204cc280facb32b38311edfcd8ac5007f6f525a5 Mon Sep 17 00:00:00 2001 From: dor-eitan <164745144+dor-eitan@users.noreply.github.com> Date: Wed, 13 Aug 2025 14:16:51 +0300 Subject: [PATCH 3/5] bugfix: mixpanel token (#193) --- src/services/analytics/mixpanel.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/analytics/mixpanel.ts b/src/services/analytics/mixpanel.ts index c2a993a1..ecbfceef 100644 --- a/src/services/analytics/mixpanel.ts +++ b/src/services/analytics/mixpanel.ts @@ -71,6 +71,7 @@ export function initializeAnalytics(config: AnalyticsOptions): Analytics { ...sendProps, agentId: this.agentId, source, + token: this.token, time: Date.now(), $insert_id: this.getRandom(), origin: window.location.href, From 0c3625d0c3167f65004b9e1a7937b009b94eaf28 Mon Sep 17 00:00:00 2001 From: dor-eitan <164745144+dor-eitan@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:15:07 +0300 Subject: [PATCH 4/5] chore: e2e env var (#194) --- .github/workflows/pr-prod-e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-prod-e2e.yml b/.github/workflows/pr-prod-e2e.yml index 885c9848..39bb2635 100644 --- a/.github/workflows/pr-prod-e2e.yml +++ b/.github/workflows/pr-prod-e2e.yml @@ -58,6 +58,7 @@ jobs: env: E2E_USER_APIKEY: ${{ secrets.E2E_USER_APIKEY }} VITE_CLIENT_KEY: ${{ secrets.VITE_CLIENT_KEY }} + ASSERT_CHAT_RESTART: 'false' run: yarn test:prod - name: Upload test results From 2edea45a053effbd753bf9349c41950913b95ca0 Mon Sep 17 00:00:00 2001 From: dor-eitan <164745144+dor-eitan@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:34:19 +0300 Subject: [PATCH 5/5] chore: ci cd auto commit version (#195) --- .github/workflows/publish-on-merge.yml | 28 +++----------------------- package.json | 2 +- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 8fa2dd65..10a111aa 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -105,6 +105,8 @@ jobs: git add package.json git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || echo "No changes to commit" git push origin prod + env: + GITHUB_TOKEN: ${{ secrets.DEVOPS_TOKEN }} - name: Sync version back to main (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' @@ -129,35 +131,11 @@ jobs: if git diff --quiet package.json; then echo "No version changes needed" else - # Create a new branch for the version sync - git checkout -b "chore/sync-version-${{ steps.version.outputs.version }}" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add package.json git commit -m "chore: sync version ${{ steps.version.outputs.version }} from prod [skip ci]" - git push origin "chore/sync-version-${{ steps.version.outputs.version }}" - - # Create pull request to merge the version sync - gh pr create \ - --repo de-id/agents-sdk \ - --title "chore: sync version ${{ steps.version.outputs.version }} from prod" \ - --body "## Version Sync - - This PR syncs the version number from the production release back to the main branch. - - ### Changes - - Updated version from previous version to ${{ steps.version.outputs.version }} - - ### Related - - Production Release: [v${{ steps.version.outputs.version }}](https://github.com/d-id/agents-sdk/releases/tag/v${{ steps.version.outputs.version }}) - - NPM Package: [@d-id/client-sdk@${{ steps.version.outputs.version }}](https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}) - - ### Next Steps - - [ ] Review the changes - - [ ] Merge when ready" \ - --base main \ - --head "chore/sync-version-${{ steps.version.outputs.version }}" \ - --label "dependencies" + git push origin main fi - name: Create GitHub Release (prod only) diff --git a/package.json b/package.json index a3803e6d..de483a50 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@d-id/client-sdk", "private": false, - "version": "1.1.7", + "version": "1.1.8", "type": "module", "description": "d-id client sdk", "repository": {