@d-id/client-sdk 1.0.8 → 1.0.10

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.
@@ -1,9 +1,10 @@
1
- import { Agent, AgentPayload, Auth, IChatPayload } from '../../../../common/types/src/index';
1
+ import { Agent, AgentPayload, Auth, ChatPayload } from '../../../../common/types/src/index';
2
2
  export declare function createAgentsApi(auth: Auth, host?: string): {
3
3
  create(payload: AgentPayload): Promise<Agent>;
4
4
  getAgents(tag?: string): Promise<Agent[]>;
5
5
  getById(id: string): Promise<Agent>;
6
6
  delete(id: string): Promise<any>;
7
7
  update(id: string, payload: AgentPayload): Promise<Agent>;
8
- chat(id: string, payload: IChatPayload): Promise<Agent>;
8
+ newChat(agentId: string): Promise<Agent>;
9
+ chat(agentId: string, payload: ChatPayload): Promise<Agent>;
9
10
  };
@@ -1,4 +1,3 @@
1
- import { StreamTextToSpeechProviders } from '../../tts';
2
1
  import { Knowledge } from './knowledge';
3
2
  import { LLM } from './llm';
4
3
  import { Presenter } from './presenter';
@@ -16,10 +15,14 @@ export interface Agent {
16
15
  preview_thumbnail?: string;
17
16
  }
18
17
  export type AgentPayload = Omit<Agent, 'type' | 'created_at' | 'modified_at' | 'id' | 'owner_id' | 'idle_video_url'>;
19
- export interface IChatPayload {
20
- voice: StreamTextToSpeechProviders;
21
- message: string;
18
+ export interface Message {
19
+ role: 'system' | 'assistant' | 'user' | 'function' | 'tool';
20
+ content: string;
21
+ name?: string;
22
+ }
23
+ export interface ChatPayload {
24
+ messages: Message[];
25
+ chatId: string;
22
26
  streamId: string;
23
27
  sessionId: string;
24
- knowledgeId: string;
25
28
  }
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  function k(r) {
2
2
  return r.type === "bearer" ? "Bearer " + r.token : r.type === "basic" ? "Basic " + btoa(`${r.username}:${r.password}`) : "Client-Key " + r.clientKey;
3
3
  }
4
- function m(r, a = "https://api.d-id.com") {
4
+ function g(r, o = "https://api.d-id.com") {
5
5
  const n = async (e, t) => {
6
- const i = await fetch(a + (e != null && e.startsWith("/") ? e : `/${e}`), {
6
+ const s = await fetch(o + (e != null && e.startsWith("/") ? e : `/${e}`), {
7
7
  ...t,
8
8
  headers: {
9
9
  ...t == null ? void 0 : t.headers,
@@ -11,15 +11,16 @@ function m(r, a = "https://api.d-id.com") {
11
11
  "Content-Type": "application/json"
12
12
  }
13
13
  });
14
- if (!i.ok) {
15
- let c = await i.text().catch(() => "Failed to fetch");
14
+ if (!s.ok) {
15
+ let u = await s.text().catch(() => "Failed to fetch");
16
16
  try {
17
- c = JSON.parse(c), c.description && (c = c.description, typeof c.description == "object" && (c = JSON.stringify(c.description)));
17
+ const c = JSON.parse(u);
18
+ c.description ? u = c.description : c.message && (u = c.message);
18
19
  } catch {
19
20
  }
20
- throw new Error(c);
21
+ throw new Error(u);
21
22
  }
22
- return i.json();
23
+ return s.json();
23
24
  };
24
25
  return {
25
26
  get(e, t) {
@@ -28,31 +29,31 @@ function m(r, a = "https://api.d-id.com") {
28
29
  method: "GET"
29
30
  });
30
31
  },
31
- post(e, t, i) {
32
+ post(e, t, s) {
32
33
  return n(e, {
33
- ...i,
34
+ ...s,
34
35
  body: JSON.stringify(t),
35
36
  method: "POST"
36
37
  });
37
38
  },
38
- delete(e, t, i) {
39
+ delete(e, t, s) {
39
40
  return n(e, {
40
- ...i,
41
+ ...s,
41
42
  body: JSON.stringify(t),
42
43
  method: "DELETE"
43
44
  });
44
45
  },
45
- patch(e, t, i) {
46
+ patch(e, t, s) {
46
47
  return n(e, {
47
- ...i,
48
+ ...s,
48
49
  body: JSON.stringify(t),
49
50
  method: "PATCH"
50
51
  });
51
52
  }
52
53
  };
53
54
  }
54
- function D(r, a = "https://api.d-id.com") {
55
- const n = m(r, `${a}/knowledge`);
55
+ function K(r, o = "https://api.d-id.com") {
56
+ const n = g(r, `${o}/knowledge`);
56
57
  return {
57
58
  createKnowledge(e) {
58
59
  return n.post("/", e);
@@ -88,8 +89,8 @@ function D(r, a = "https://api.d-id.com") {
88
89
  }
89
90
  };
90
91
  }
91
- function K(r, a = "https://api.d-id.com") {
92
- const n = m(r, `${a}/agents`);
92
+ function O(r, o = "https://api.d-id.com") {
93
+ const n = g(r, `${o}/agents`);
93
94
  return {
94
95
  create(e) {
95
96
  return n.post("/", e);
@@ -106,13 +107,16 @@ function K(r, a = "https://api.d-id.com") {
106
107
  update(e, t) {
107
108
  return n.patch(`/${e}`, t);
108
109
  },
110
+ newChat(e) {
111
+ return n.patch(`/${e}/chat/new`);
112
+ },
109
113
  chat(e, t) {
110
114
  return n.post(`/${e}/chat`, t);
111
115
  }
112
116
  };
113
117
  }
114
- function A(r, a) {
115
- const n = m(r, a);
118
+ function A(r, o) {
119
+ const n = g(r, o);
116
120
  return {
117
121
  createStream(e) {
118
122
  return n.post("/clips/streams", {
@@ -121,22 +125,22 @@ function A(r, a) {
121
125
  compatibility_mode: e.compatibility_mode
122
126
  });
123
127
  },
124
- startConnection(e, t, i) {
128
+ startConnection(e, t, s) {
125
129
  return n.post(`/clips/streams/${e}/sdp`, {
126
- session_id: i,
130
+ session_id: s,
127
131
  answer: t
128
132
  });
129
133
  },
130
- addIceCandidate(e, t, i) {
134
+ addIceCandidate(e, t, s) {
131
135
  return n.post(`/clips/streams/${e}/ice`, {
132
- session_id: i,
136
+ session_id: s,
133
137
  ...t
134
138
  });
135
139
  },
136
- sendStreamRequest(e, t, i) {
140
+ sendStreamRequest(e, t, s) {
137
141
  return n.post(`/clips/streams/${e}`, {
138
142
  session_id: t,
139
- ...i
143
+ ...s
140
144
  });
141
145
  },
142
146
  close(e, t) {
@@ -146,8 +150,8 @@ function A(r, a) {
146
150
  }
147
151
  };
148
152
  }
149
- function O(r, a) {
150
- const n = m(r, a);
153
+ function T(r, o) {
154
+ const n = g(r, o);
151
155
  return {
152
156
  createStream(e) {
153
157
  return n.post("/talks/streams", {
@@ -157,22 +161,22 @@ function O(r, a) {
157
161
  config: e.config
158
162
  });
159
163
  },
160
- startConnection(e, t, i) {
164
+ startConnection(e, t, s) {
161
165
  return n.post(`/talks/streams/${e}/sdp`, {
162
- session_id: i,
166
+ session_id: s,
163
167
  answer: t
164
168
  });
165
169
  },
166
- addIceCandidate(e, t, i) {
170
+ addIceCandidate(e, t, s) {
167
171
  return n.post(`/talks/streams/${e}/ice`, {
168
- session_id: i,
172
+ session_id: s,
169
173
  ...t
170
174
  });
171
175
  },
172
- sendStreamRequest(e, t, i) {
176
+ sendStreamRequest(e, t, s) {
173
177
  return n.post(`/talks/streams/${e}`, {
174
178
  session_id: t,
175
- ...i
179
+ ...s
176
180
  });
177
181
  },
178
182
  close(e, t) {
@@ -182,61 +186,61 @@ function O(r, a) {
182
186
  }
183
187
  };
184
188
  }
185
- var p = /* @__PURE__ */ ((r) => (r.Idle = "IDLE", r.Streaming = "STREAMING", r))(p || {}), w = /* @__PURE__ */ ((r) => (r.Clip = "clip", r.Talk = "talk", r))(w || {});
189
+ var m = /* @__PURE__ */ ((r) => (r.Idle = "IDLE", r.Streaming = "STREAMING", r))(m || {}), f = /* @__PURE__ */ ((r) => (r.Clip = "clip", r.Talk = "talk", r))(f || {});
186
190
  let $ = !1;
187
- const d = (r, a) => $ && console.log(r, a), T = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
188
- async function R(r, {
189
- debug: a = !1,
191
+ const d = (r, o) => $ && console.log(r, o), D = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
192
+ async function E(r, {
193
+ debug: o = !1,
190
194
  callbacks: n,
191
195
  auth: e,
192
196
  baseURL: t = "https://api.d-id.com"
193
197
  }) {
194
- $ = a;
195
- let i = null;
198
+ $ = o;
199
+ let s = null;
196
200
  const {
197
- startConnection: c,
198
- sendStreamRequest: g,
201
+ startConnection: u,
202
+ sendStreamRequest: c,
199
203
  close: h,
200
204
  createStream: S,
201
- addIceCandidate: y
202
- } = r.videoType === w.Clip ? A(e, t) : O(e, t), {
203
- id: u,
204
- offer: _,
205
+ addIceCandidate: _
206
+ } = r.videoType === f.Clip ? A(e, t) : T(e, t), {
207
+ id: l,
208
+ offer: y,
205
209
  ice_servers: I,
206
- session_id: l
207
- } = await S(r), o = new T({
210
+ session_id: p
211
+ } = await S(r), a = new D({
208
212
  iceServers: I
209
- }), C = o.createDataChannel("JanusDataChannel");
210
- if (!l)
213
+ }), C = a.createDataChannel("JanusDataChannel");
214
+ if (!p)
211
215
  throw new Error("Could not create session_id");
212
- o.onicecandidate = (s) => {
213
- d("peerConnection.onicecandidate", s), s.candidate && s.candidate.sdpMid && s.candidate.sdpMLineIndex !== null && y(u, {
214
- candidate: s.candidate.candidate,
215
- sdpMid: s.candidate.sdpMid,
216
- sdpMLineIndex: s.candidate.sdpMLineIndex
217
- }, l);
218
- }, o.oniceconnectionstatechange = () => {
219
- d("peerConnection.oniceconnectionstatechange => " + o.iceConnectionState), n.onConnectionStateChange(o.iceConnectionState);
220
- }, o.ontrack = (s) => {
221
- d("peerConnection.ontrack", s), i = s.streams[0], n.onSrcObjectReady(i);
222
- }, C.onmessage = (s) => {
223
- C.readyState === "open" && n.onStreamingStateChange(s.data === "stream/done" ? p.Idle : p.Streaming);
224
- }, await o.setRemoteDescription(_), d("set remote description OK");
225
- const f = await o.createAnswer();
226
- return d("create answer OK"), await o.setLocalDescription(f), d("set local description OK"), await c(u, f, l), d("start connection OK"), {
227
- speak(s) {
228
- return g(u, l, s);
216
+ a.onicecandidate = (i) => {
217
+ d("peerConnection.onicecandidate", i), i.candidate && i.candidate.sdpMid && i.candidate.sdpMLineIndex !== null && _(l, {
218
+ candidate: i.candidate.candidate,
219
+ sdpMid: i.candidate.sdpMid,
220
+ sdpMLineIndex: i.candidate.sdpMLineIndex
221
+ }, p);
222
+ }, a.oniceconnectionstatechange = () => {
223
+ d("peerConnection.oniceconnectionstatechange => " + a.iceConnectionState), n.onConnectionStateChange(a.iceConnectionState);
224
+ }, a.ontrack = (i) => {
225
+ d("peerConnection.ontrack", i), s = i.streams[0], n.onSrcObjectReady(s);
226
+ }, C.onmessage = (i) => {
227
+ C.readyState === "open" && n.onStreamingStateChange(i.data === "stream/done" ? m.Idle : m.Streaming);
228
+ }, await a.setRemoteDescription(y), d("set remote description OK");
229
+ const w = await a.createAnswer();
230
+ return d("create answer OK"), await a.setLocalDescription(w), d("set local description OK"), await u(l, w, p), d("start connection OK"), {
231
+ speak(i) {
232
+ return c(l, p, i);
229
233
  },
230
234
  async terminate() {
231
- u && (i && (i.getTracks().forEach((s) => s.stop()), i = null), o && (o.close(), o.oniceconnectionstatechange = null, o.onnegotiationneeded = null, o.onicecandidate = null, o.ontrack = null), await h(u, l), n.onConnectionStateChange("closed"), n.onStreamingStateChange(p.Idle));
235
+ l && (s && (s.getTracks().forEach((i) => i.stop()), s = null), a && (a.close(), a.oniceconnectionstatechange = null, a.onnegotiationneeded = null, a.onicecandidate = null, a.ontrack = null), await h(l, p), n.onConnectionStateChange("closed"), n.onStreamingStateChange(m.Idle));
232
236
  },
233
- sessionId: l,
234
- streamId: u
237
+ sessionId: p,
238
+ streamId: l
235
239
  };
236
240
  }
237
241
  export {
238
- K as createAgentsApi,
239
- m as createClient,
240
- D as createKnowledgeApi,
241
- R as createStreamingManager
242
+ O as createAgentsApi,
243
+ g as createClient,
244
+ K as createKnowledgeApi,
245
+ E as createStreamingManager
242
246
  };
@@ -1 +1 @@
1
- (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.index={}))})(this,function(d){"use strict";function m(r){return r.type==="bearer"?"Bearer "+r.token:r.type==="basic"?"Basic "+btoa(`${r.username}:${r.password}`):"Client-Key "+r.clientKey}function g(r,a="https://api.d-id.com"){const n=async(e,t)=>{const i=await fetch(a+(e!=null&&e.startsWith("/")?e:`/${e}`),{...t,headers:{...t==null?void 0:t.headers,Authorization:m(r),"Content-Type":"application/json"}});if(!i.ok){let c=await i.text().catch(()=>"Failed to fetch");try{c=JSON.parse(c),c.description&&(c=c.description,typeof c.description=="object"&&(c=JSON.stringify(c.description)))}catch{}throw new Error(c)}return i.json()};return{get(e,t){return n(e,{...t,method:"GET"})},post(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"POST"})},delete(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"DELETE"})},patch(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"PATCH"})}}}function y(r,a="https://api.d-id.com"){const n=g(r,`${a}/knowledge`);return{createKnowledge(e){return n.post("/",e)},getKnowledgeBase(){return n.get("/")},getKnowledge(e){return n.get(`/${e}`)},deleteKnowledge(e){return n.delete(`/${e}`)},createDocument(e,t){return n.post(`/${e}/documents`,t)},deleteDocument(e,t){return n.delete(`/${e}/documents/${t}`)},getDocuments(e){return n.get(`/${e}/documents`)},getDocument(e,t){return n.get(`/${e}/documents/${t}`)},getRecords(e,t){return n.get(`/${e}/documents/${t}/records`)},query(e,t){return n.post(`/${e}/query`,{query:t})}}}function _(r,a="https://api.d-id.com"){const n=g(r,`${a}/agents`);return{create(e){return n.post("/",e)},getAgents(e){return n.get(`/${e?`?tag=${e}`:""}`)},getById(e){return n.get(`/${e}`)},delete(e){return n.delete(`/${e}`)},update(e,t){return n.patch(`/${e}`,t)},chat(e,t){return n.post(`/${e}/chat`,t)}}}function A(r,a){const n=g(r,a);return{createStream(e){return n.post("/clips/streams",{driver_id:e.driver_id,presenter_id:e.presenter_id,compatibility_mode:e.compatibility_mode})},startConnection(e,t,i){return n.post(`/clips/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/clips/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/clips/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/clips/streams/${e}`,{session_id:t})}}}function I(r,a){const n=g(r,a);return{createStream(e){return n.post("/talks/streams",{source_url:e.source_url,driver_url:e.driver_url,face:e.face,config:e.config})},startConnection(e,t,i){return n.post(`/talks/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/talks/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/talks/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/talks/streams/${e}`,{session_id:t})}}}var f=(r=>(r.Idle="IDLE",r.Streaming="STREAMING",r))(f||{}),C=(r=>(r.Clip="clip",r.Talk="talk",r))(C||{});let w=!1;const u=(r,a)=>w&&console.log(r,a),T=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function O(r,{debug:a=!1,callbacks:n,auth:e,baseURL:t="https://api.d-id.com"}){w=a;let i=null;const{startConnection:c,sendStreamRequest:h,close:b,createStream:k,addIceCandidate:K}=r.videoType===C.Clip?A(e,t):I(e,t),{id:l,offer:D,ice_servers:M,session_id:p}=await k(r),o=new T({iceServers:M}),$=o.createDataChannel("JanusDataChannel");if(!p)throw new Error("Could not create session_id");o.onicecandidate=s=>{u("peerConnection.onicecandidate",s),s.candidate&&s.candidate.sdpMid&&s.candidate.sdpMLineIndex!==null&&K(l,{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex},p)},o.oniceconnectionstatechange=()=>{u("peerConnection.oniceconnectionstatechange => "+o.iceConnectionState),n.onConnectionStateChange(o.iceConnectionState)},o.ontrack=s=>{u("peerConnection.ontrack",s),i=s.streams[0],n.onSrcObjectReady(i)},$.onmessage=s=>{$.readyState==="open"&&n.onStreamingStateChange(s.data==="stream/done"?f.Idle:f.Streaming)},await o.setRemoteDescription(D),u("set remote description OK");const S=await o.createAnswer();return u("create answer OK"),await o.setLocalDescription(S),u("set local description OK"),await c(l,S,p),u("start connection OK"),{speak(s){return h(l,p,s)},async terminate(){l&&(i&&(i.getTracks().forEach(s=>s.stop()),i=null),o&&(o.close(),o.oniceconnectionstatechange=null,o.onnegotiationneeded=null,o.onicecandidate=null,o.ontrack=null),await b(l,p),n.onConnectionStateChange("closed"),n.onStreamingStateChange(f.Idle))},sessionId:p,streamId:l}}d.createAgentsApi=_,d.createClient=g,d.createKnowledgeApi=y,d.createStreamingManager=O,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(c=typeof globalThis<"u"?globalThis:c||self,g(c.index={}))})(this,function(c){"use strict";function g(r){return r.type==="bearer"?"Bearer "+r.token:r.type==="basic"?"Basic "+btoa(`${r.username}:${r.password}`):"Client-Key "+r.clientKey}function f(r,o="https://api.d-id.com"){const n=async(e,t)=>{const i=await fetch(o+(e!=null&&e.startsWith("/")?e:`/${e}`),{...t,headers:{...t==null?void 0:t.headers,Authorization:g(r),"Content-Type":"application/json"}});if(!i.ok){let l=await i.text().catch(()=>"Failed to fetch");try{const u=JSON.parse(l);u.description?l=u.description:u.message&&(l=u.message)}catch{}throw new Error(l)}return i.json()};return{get(e,t){return n(e,{...t,method:"GET"})},post(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"POST"})},delete(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"DELETE"})},patch(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"PATCH"})}}}function y(r,o="https://api.d-id.com"){const n=f(r,`${o}/knowledge`);return{createKnowledge(e){return n.post("/",e)},getKnowledgeBase(){return n.get("/")},getKnowledge(e){return n.get(`/${e}`)},deleteKnowledge(e){return n.delete(`/${e}`)},createDocument(e,t){return n.post(`/${e}/documents`,t)},deleteDocument(e,t){return n.delete(`/${e}/documents/${t}`)},getDocuments(e){return n.get(`/${e}/documents`)},getDocument(e,t){return n.get(`/${e}/documents/${t}`)},getRecords(e,t){return n.get(`/${e}/documents/${t}/records`)},query(e,t){return n.post(`/${e}/query`,{query:t})}}}function _(r,o="https://api.d-id.com"){const n=f(r,`${o}/agents`);return{create(e){return n.post("/",e)},getAgents(e){return n.get(`/${e?`?tag=${e}`:""}`)},getById(e){return n.get(`/${e}`)},delete(e){return n.delete(`/${e}`)},update(e,t){return n.patch(`/${e}`,t)},newChat(e){return n.patch(`/${e}/chat/new`)},chat(e,t){return n.post(`/${e}/chat`,t)}}}function A(r,o){const n=f(r,o);return{createStream(e){return n.post("/clips/streams",{driver_id:e.driver_id,presenter_id:e.presenter_id,compatibility_mode:e.compatibility_mode})},startConnection(e,t,i){return n.post(`/clips/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/clips/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/clips/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/clips/streams/${e}`,{session_id:t})}}}function I(r,o){const n=f(r,o);return{createStream(e){return n.post("/talks/streams",{source_url:e.source_url,driver_url:e.driver_url,face:e.face,config:e.config})},startConnection(e,t,i){return n.post(`/talks/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/talks/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/talks/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/talks/streams/${e}`,{session_id:t})}}}var C=(r=>(r.Idle="IDLE",r.Streaming="STREAMING",r))(C||{}),w=(r=>(r.Clip="clip",r.Talk="talk",r))(w||{});let h=!1;const d=(r,o)=>h&&console.log(r,o),T=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function k(r,{debug:o=!1,callbacks:n,auth:e,baseURL:t="https://api.d-id.com"}){h=o;let i=null;const{startConnection:l,sendStreamRequest:u,close:K,createStream:O,addIceCandidate:b}=r.videoType===w.Clip?A(e,t):I(e,t),{id:p,offer:D,ice_servers:E,session_id:m}=await O(r),a=new T({iceServers:E}),$=a.createDataChannel("JanusDataChannel");if(!m)throw new Error("Could not create session_id");a.onicecandidate=s=>{d("peerConnection.onicecandidate",s),s.candidate&&s.candidate.sdpMid&&s.candidate.sdpMLineIndex!==null&&b(p,{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex},m)},a.oniceconnectionstatechange=()=>{d("peerConnection.oniceconnectionstatechange => "+a.iceConnectionState),n.onConnectionStateChange(a.iceConnectionState)},a.ontrack=s=>{d("peerConnection.ontrack",s),i=s.streams[0],n.onSrcObjectReady(i)},$.onmessage=s=>{$.readyState==="open"&&n.onStreamingStateChange(s.data==="stream/done"?C.Idle:C.Streaming)},await a.setRemoteDescription(D),d("set remote description OK");const S=await a.createAnswer();return d("create answer OK"),await a.setLocalDescription(S),d("set local description OK"),await l(p,S,m),d("start connection OK"),{speak(s){return u(p,m,s)},async terminate(){p&&(i&&(i.getTracks().forEach(s=>s.stop()),i=null),a&&(a.close(),a.oniceconnectionstatechange=null,a.onnegotiationneeded=null,a.onicecandidate=null,a.ontrack=null),await K(p,m),n.onConnectionStateChange("closed"),n.onStreamingStateChange(C.Idle))},sessionId:m,streamId:p}}c.createAgentsApi=_,c.createClient=f,c.createKnowledgeApi=y,c.createStreamingManager=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d-id/client-sdk",
3
3
  "private": false,
4
- "version": "1.0.8",
4
+ "version": "1.0.10",
5
5
  "type": "module",
6
6
  "description": "d-id client sdk",
7
7
  "repository": {