@d-id/client-sdk 1.0.12 → 1.0.14
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/apps/sdk/lib/index.d.ts +1 -2
- package/dist/index.js +136 -187
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/apps/sdk/lib/connectToSocket.d.ts +0 -15
package/dist/index.js
CHANGED
|
@@ -1,292 +1,241 @@
|
|
|
1
|
-
function
|
|
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
|
|
5
|
-
const
|
|
4
|
+
function p(r, o = "https://api.d-id.com") {
|
|
5
|
+
const n = async (e, t) => {
|
|
6
6
|
const s = await fetch(o + (e != null && e.startsWith("/") ? e : `/${e}`), {
|
|
7
|
-
...
|
|
7
|
+
...t,
|
|
8
8
|
headers: {
|
|
9
|
-
...
|
|
10
|
-
Authorization:
|
|
9
|
+
...t == null ? void 0 : t.headers,
|
|
10
|
+
Authorization: k(r),
|
|
11
11
|
"Content-Type": "application/json"
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
if (!s.ok) {
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
const d = JSON.parse(l);
|
|
18
|
-
d.description ? l = d.description : d.message && (l = d.message);
|
|
19
|
-
} catch {
|
|
20
|
-
}
|
|
21
|
-
throw new Error(l);
|
|
15
|
+
let m = await s.text().catch(() => "Failed to fetch");
|
|
16
|
+
throw new Error(m);
|
|
22
17
|
}
|
|
23
18
|
return s.json();
|
|
24
19
|
};
|
|
25
20
|
return {
|
|
26
|
-
get(e,
|
|
27
|
-
return
|
|
28
|
-
...
|
|
21
|
+
get(e, t) {
|
|
22
|
+
return n(e, {
|
|
23
|
+
...t,
|
|
29
24
|
method: "GET"
|
|
30
25
|
});
|
|
31
26
|
},
|
|
32
|
-
post(e,
|
|
33
|
-
return
|
|
27
|
+
post(e, t, s) {
|
|
28
|
+
return n(e, {
|
|
34
29
|
...s,
|
|
35
|
-
body: JSON.stringify(
|
|
30
|
+
body: JSON.stringify(t),
|
|
36
31
|
method: "POST"
|
|
37
32
|
});
|
|
38
33
|
},
|
|
39
|
-
delete(e,
|
|
40
|
-
return
|
|
34
|
+
delete(e, t, s) {
|
|
35
|
+
return n(e, {
|
|
41
36
|
...s,
|
|
42
|
-
body: JSON.stringify(
|
|
37
|
+
body: JSON.stringify(t),
|
|
43
38
|
method: "DELETE"
|
|
44
39
|
});
|
|
45
40
|
},
|
|
46
|
-
patch(e,
|
|
47
|
-
return
|
|
41
|
+
patch(e, t, s) {
|
|
42
|
+
return n(e, {
|
|
48
43
|
...s,
|
|
49
|
-
body: JSON.stringify(
|
|
44
|
+
body: JSON.stringify(t),
|
|
50
45
|
method: "PATCH"
|
|
51
46
|
});
|
|
52
47
|
}
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
return {
|
|
58
|
-
create(e) {
|
|
59
|
-
return t.post("/", e);
|
|
60
|
-
},
|
|
61
|
-
getAgents(e) {
|
|
62
|
-
return t.get(`/${e ? `?tag=${e}` : ""}`);
|
|
63
|
-
},
|
|
64
|
-
getById(e) {
|
|
65
|
-
return t.get(`/${e}`);
|
|
66
|
-
},
|
|
67
|
-
delete(e) {
|
|
68
|
-
return t.delete(`/${e}`);
|
|
69
|
-
},
|
|
70
|
-
update(e, n) {
|
|
71
|
-
return t.patch(`/${e}`, n);
|
|
72
|
-
},
|
|
73
|
-
newChat(e) {
|
|
74
|
-
return t.post(`/${e}/chat`);
|
|
75
|
-
},
|
|
76
|
-
chat(e, n, s) {
|
|
77
|
-
return t.post(`/${e}/chat/${n}`, s);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function R(r, o = "https://api.d-id.com") {
|
|
82
|
-
const t = $(r, `${o}/knowledge`);
|
|
50
|
+
function K(r, o = "https://api.d-id.com") {
|
|
51
|
+
const n = p(r, `${o}/knowledge`);
|
|
83
52
|
return {
|
|
84
53
|
createKnowledge(e) {
|
|
85
|
-
return
|
|
54
|
+
return n.post("/", e);
|
|
86
55
|
},
|
|
87
56
|
getKnowledgeBase() {
|
|
88
|
-
return
|
|
57
|
+
return n.get("/");
|
|
89
58
|
},
|
|
90
59
|
getKnowledge(e) {
|
|
91
|
-
return
|
|
60
|
+
return n.get(`/${e}`);
|
|
92
61
|
},
|
|
93
62
|
deleteKnowledge(e) {
|
|
94
|
-
return
|
|
63
|
+
return n.delete(`/${e}`);
|
|
95
64
|
},
|
|
96
|
-
createDocument(e,
|
|
97
|
-
return
|
|
65
|
+
createDocument(e, t) {
|
|
66
|
+
return n.post(`/${e}/documents`, t);
|
|
98
67
|
},
|
|
99
|
-
deleteDocument(e,
|
|
100
|
-
return
|
|
68
|
+
deleteDocument(e, t) {
|
|
69
|
+
return n.delete(`/${e}/documents/${t}`);
|
|
101
70
|
},
|
|
102
71
|
getDocuments(e) {
|
|
103
|
-
return
|
|
72
|
+
return n.get(`/${e}/documents`);
|
|
104
73
|
},
|
|
105
|
-
getDocument(e,
|
|
106
|
-
return
|
|
74
|
+
getDocument(e, t) {
|
|
75
|
+
return n.get(`/${e}/documents/${t}`);
|
|
107
76
|
},
|
|
108
|
-
getRecords(e,
|
|
109
|
-
return
|
|
77
|
+
getRecords(e, t) {
|
|
78
|
+
return n.get(`/${e}/documents/${t}/records`);
|
|
110
79
|
},
|
|
111
|
-
query(e,
|
|
112
|
-
return
|
|
113
|
-
query:
|
|
80
|
+
query(e, t) {
|
|
81
|
+
return n.post(`/${e}/query`, {
|
|
82
|
+
query: t
|
|
114
83
|
});
|
|
115
84
|
}
|
|
116
85
|
};
|
|
117
86
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.log(c), g == null || g(c), t(c);
|
|
142
|
-
}, u.onopen = (c) => {
|
|
143
|
-
d == null || d(c), o(u);
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async function M(r) {
|
|
148
|
-
const {
|
|
149
|
-
retries: o = 1
|
|
150
|
-
} = r;
|
|
151
|
-
let t = null;
|
|
152
|
-
for (let e = 0; (t == null ? void 0 : t.readyState) !== WebSocket.OPEN; e++)
|
|
153
|
-
try {
|
|
154
|
-
t = await A(r);
|
|
155
|
-
} catch (n) {
|
|
156
|
-
if (e === o)
|
|
157
|
-
throw n;
|
|
158
|
-
await T(e * 500);
|
|
87
|
+
function O(r, o = "https://api.d-id.com") {
|
|
88
|
+
const n = p(r, `${o}/agents`);
|
|
89
|
+
return {
|
|
90
|
+
create(e) {
|
|
91
|
+
return n.post("/", e);
|
|
92
|
+
},
|
|
93
|
+
getAgents(e) {
|
|
94
|
+
return n.get(`/${e ? `?tag=${e}` : ""}`);
|
|
95
|
+
},
|
|
96
|
+
getById(e) {
|
|
97
|
+
return n.get(`/${e}`);
|
|
98
|
+
},
|
|
99
|
+
delete(e) {
|
|
100
|
+
return n.delete(`/${e}`);
|
|
101
|
+
},
|
|
102
|
+
update(e, t) {
|
|
103
|
+
return n.patch(`/${e}`, t);
|
|
104
|
+
},
|
|
105
|
+
newChat(e) {
|
|
106
|
+
return n.post(`/${e}/chat`);
|
|
107
|
+
},
|
|
108
|
+
chat(e, t, s) {
|
|
109
|
+
return n.post(`/${e}/chat/${t}`, s);
|
|
159
110
|
}
|
|
160
|
-
|
|
111
|
+
};
|
|
161
112
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
113
|
+
function A(r, o) {
|
|
114
|
+
const n = p(r, o);
|
|
164
115
|
return {
|
|
165
116
|
createStream(e) {
|
|
166
|
-
return
|
|
117
|
+
return n.post("/clips/streams", {
|
|
167
118
|
driver_id: e.driver_id,
|
|
168
119
|
presenter_id: e.presenter_id,
|
|
169
120
|
compatibility_mode: e.compatibility_mode
|
|
170
121
|
});
|
|
171
122
|
},
|
|
172
|
-
startConnection(e,
|
|
173
|
-
return
|
|
123
|
+
startConnection(e, t, s) {
|
|
124
|
+
return n.post(`/clips/streams/${e}/sdp`, {
|
|
174
125
|
session_id: s,
|
|
175
|
-
answer:
|
|
126
|
+
answer: t
|
|
176
127
|
});
|
|
177
128
|
},
|
|
178
|
-
addIceCandidate(e,
|
|
179
|
-
return
|
|
129
|
+
addIceCandidate(e, t, s) {
|
|
130
|
+
return n.post(`/clips/streams/${e}/ice`, {
|
|
180
131
|
session_id: s,
|
|
181
|
-
...
|
|
132
|
+
...t
|
|
182
133
|
});
|
|
183
134
|
},
|
|
184
|
-
sendStreamRequest(e,
|
|
185
|
-
return
|
|
186
|
-
session_id:
|
|
135
|
+
sendStreamRequest(e, t, s) {
|
|
136
|
+
return n.post(`/clips/streams/${e}`, {
|
|
137
|
+
session_id: t,
|
|
187
138
|
...s
|
|
188
139
|
});
|
|
189
140
|
},
|
|
190
|
-
close(e,
|
|
191
|
-
return
|
|
192
|
-
session_id:
|
|
141
|
+
close(e, t) {
|
|
142
|
+
return n.delete(`/clips/streams/${e}`, {
|
|
143
|
+
session_id: t
|
|
193
144
|
});
|
|
194
145
|
}
|
|
195
146
|
};
|
|
196
147
|
}
|
|
197
|
-
function
|
|
198
|
-
const
|
|
148
|
+
function T(r, o) {
|
|
149
|
+
const n = p(r, o);
|
|
199
150
|
return {
|
|
200
151
|
createStream(e) {
|
|
201
|
-
return
|
|
152
|
+
return n.post("/talks/streams", {
|
|
202
153
|
source_url: e.source_url,
|
|
203
154
|
driver_url: e.driver_url,
|
|
204
155
|
face: e.face,
|
|
205
156
|
config: e.config
|
|
206
157
|
});
|
|
207
158
|
},
|
|
208
|
-
startConnection(e,
|
|
209
|
-
return
|
|
159
|
+
startConnection(e, t, s) {
|
|
160
|
+
return n.post(`/talks/streams/${e}/sdp`, {
|
|
210
161
|
session_id: s,
|
|
211
|
-
answer:
|
|
162
|
+
answer: t
|
|
212
163
|
});
|
|
213
164
|
},
|
|
214
|
-
addIceCandidate(e,
|
|
215
|
-
return
|
|
165
|
+
addIceCandidate(e, t, s) {
|
|
166
|
+
return n.post(`/talks/streams/${e}/ice`, {
|
|
216
167
|
session_id: s,
|
|
217
|
-
...
|
|
168
|
+
...t
|
|
218
169
|
});
|
|
219
170
|
},
|
|
220
|
-
sendStreamRequest(e,
|
|
221
|
-
return
|
|
222
|
-
session_id:
|
|
171
|
+
sendStreamRequest(e, t, s) {
|
|
172
|
+
return n.post(`/talks/streams/${e}`, {
|
|
173
|
+
session_id: t,
|
|
223
174
|
...s
|
|
224
175
|
});
|
|
225
176
|
},
|
|
226
|
-
close(e,
|
|
227
|
-
return
|
|
228
|
-
session_id:
|
|
177
|
+
close(e, t) {
|
|
178
|
+
return n.delete(`/talks/streams/${e}`, {
|
|
179
|
+
session_id: t
|
|
229
180
|
});
|
|
230
181
|
}
|
|
231
182
|
};
|
|
232
183
|
}
|
|
233
|
-
var
|
|
234
|
-
let
|
|
235
|
-
const
|
|
236
|
-
async function
|
|
184
|
+
var l = /* @__PURE__ */ ((r) => (r.Idle = "IDLE", r.Streaming = "STREAMING", r))(l || {}), w = /* @__PURE__ */ ((r) => (r.Clip = "clip", r.Talk = "talk", r))(w || {});
|
|
185
|
+
let $ = !1;
|
|
186
|
+
const c = (r, o) => $ && console.log(r, o), D = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
187
|
+
async function R(r, {
|
|
237
188
|
debug: o = !1,
|
|
238
|
-
callbacks:
|
|
189
|
+
callbacks: n,
|
|
239
190
|
auth: e,
|
|
240
|
-
baseURL:
|
|
191
|
+
baseURL: t = "https://api.d-id.com"
|
|
241
192
|
}) {
|
|
242
|
-
|
|
193
|
+
$ = o;
|
|
243
194
|
let s = null;
|
|
244
195
|
const {
|
|
245
|
-
startConnection:
|
|
246
|
-
sendStreamRequest:
|
|
247
|
-
close:
|
|
248
|
-
createStream:
|
|
249
|
-
addIceCandidate:
|
|
250
|
-
} = r.videoType ===
|
|
251
|
-
id:
|
|
252
|
-
offer:
|
|
253
|
-
ice_servers:
|
|
254
|
-
session_id:
|
|
255
|
-
} = await
|
|
256
|
-
iceServers:
|
|
257
|
-
}),
|
|
258
|
-
if (!
|
|
196
|
+
startConnection: m,
|
|
197
|
+
sendStreamRequest: f,
|
|
198
|
+
close: h,
|
|
199
|
+
createStream: S,
|
|
200
|
+
addIceCandidate: _
|
|
201
|
+
} = r.videoType === w.Clip ? A(e, t) : T(e, t), {
|
|
202
|
+
id: d,
|
|
203
|
+
offer: y,
|
|
204
|
+
ice_servers: I,
|
|
205
|
+
session_id: u
|
|
206
|
+
} = await S(r), i = new D({
|
|
207
|
+
iceServers: I
|
|
208
|
+
}), g = i.createDataChannel("JanusDataChannel");
|
|
209
|
+
if (!u)
|
|
259
210
|
throw new Error("Could not create session_id");
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
candidate:
|
|
263
|
-
sdpMid:
|
|
264
|
-
sdpMLineIndex:
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
}, await
|
|
273
|
-
const
|
|
274
|
-
return
|
|
275
|
-
speak(
|
|
276
|
-
return d
|
|
211
|
+
i.onicecandidate = (a) => {
|
|
212
|
+
c("peerConnection.onicecandidate", a), a.candidate && a.candidate.sdpMid && a.candidate.sdpMLineIndex !== null && _(d, {
|
|
213
|
+
candidate: a.candidate.candidate,
|
|
214
|
+
sdpMid: a.candidate.sdpMid,
|
|
215
|
+
sdpMLineIndex: a.candidate.sdpMLineIndex
|
|
216
|
+
}, u);
|
|
217
|
+
}, i.oniceconnectionstatechange = () => {
|
|
218
|
+
c("peerConnection.oniceconnectionstatechange => " + i.iceConnectionState), n.onConnectionStateChange(i.iceConnectionState);
|
|
219
|
+
}, i.ontrack = (a) => {
|
|
220
|
+
c("peerConnection.ontrack", a), s = a.streams[0], n.onSrcObjectReady(s);
|
|
221
|
+
}, g.onmessage = (a) => {
|
|
222
|
+
g.readyState === "open" && n.onStreamingStateChange(a.data === "stream/done" ? l.Idle : l.Streaming);
|
|
223
|
+
}, await i.setRemoteDescription(y), c("set remote description OK");
|
|
224
|
+
const C = await i.createAnswer();
|
|
225
|
+
return c("create answer OK"), await i.setLocalDescription(C), c("set local description OK"), await m(d, C, u), c("start connection OK"), {
|
|
226
|
+
speak(a) {
|
|
227
|
+
return f(d, u, a);
|
|
277
228
|
},
|
|
278
229
|
async terminate() {
|
|
279
|
-
|
|
230
|
+
d && (s && (s.getTracks().forEach((a) => a.stop()), s = null), i && (i.close(), i.oniceconnectionstatechange = null, i.onnegotiationneeded = null, i.onicecandidate = null, i.ontrack = null), await h(d, u), n.onConnectionStateChange("closed"), n.onStreamingStateChange(l.Idle));
|
|
280
231
|
},
|
|
281
|
-
sessionId:
|
|
282
|
-
streamId:
|
|
232
|
+
sessionId: u,
|
|
233
|
+
streamId: d
|
|
283
234
|
};
|
|
284
235
|
}
|
|
285
236
|
export {
|
|
286
|
-
A as connect,
|
|
287
|
-
M as connectToSocket,
|
|
288
237
|
O as createAgentsApi,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
238
|
+
p as createClient,
|
|
239
|
+
K as createKnowledgeApi,
|
|
240
|
+
R as createStreamingManager
|
|
292
241
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(c=typeof globalThis<"u"?globalThis:c||self,p(c.index={}))})(this,function(c){"use strict";function p(r){return r.type==="bearer"?"Bearer "+r.token:r.type==="basic"?"Basic "+btoa(`${r.username}:${r.password}`):"Client-Key "+r.clientKey}function m(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:p(r),"Content-Type":"application/json"}});if(!i.ok){let f=await i.text().catch(()=>"Failed to fetch");throw new Error(f)}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 S(r,o="https://api.d-id.com"){const n=m(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 y(r,o="https://api.d-id.com"){const n=m(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.post(`/${e}/chat`)},chat(e,t,i){return n.post(`/${e}/chat/${t}`,i)}}}function _(r,o){const n=m(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 A(r,o){const n=m(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 g=(r=>(r.Idle="IDLE",r.Streaming="STREAMING",r))(g||{}),C=(r=>(r.Clip="clip",r.Talk="talk",r))(C||{});let w=!1;const d=(r,o)=>w&&console.log(r,o),I=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function T(r,{debug:o=!1,callbacks:n,auth:e,baseURL:t="https://api.d-id.com"}){w=o;let i=null;const{startConnection:f,sendStreamRequest:k,close:K,createStream:b,addIceCandidate:D}=r.videoType===C.Clip?_(e,t):A(e,t),{id:u,offer:O,ice_servers:M,session_id:l}=await b(r),a=new I({iceServers:M}),$=a.createDataChannel("JanusDataChannel");if(!l)throw new Error("Could not create session_id");a.onicecandidate=s=>{d("peerConnection.onicecandidate",s),s.candidate&&s.candidate.sdpMid&&s.candidate.sdpMLineIndex!==null&&D(u,{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex},l)},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"?g.Idle:g.Streaming)},await a.setRemoteDescription(O),d("set remote description OK");const h=await a.createAnswer();return d("create answer OK"),await a.setLocalDescription(h),d("set local description OK"),await f(u,h,l),d("start connection OK"),{speak(s){return k(u,l,s)},async terminate(){u&&(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(u,l),n.onConnectionStateChange("closed"),n.onStreamingStateChange(g.Idle))},sessionId:l,streamId:u}}c.createAgentsApi=y,c.createClient=m,c.createKnowledgeApi=S,c.createStreamingManager=T,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Auth } from '../../../common/types/src/auth';
|
|
2
|
-
interface Options {
|
|
3
|
-
auth: Auth;
|
|
4
|
-
retries?: number;
|
|
5
|
-
callbacks: {
|
|
6
|
-
onMessage: (event: MessageEvent) => void;
|
|
7
|
-
onOpen?: (event: Event) => void;
|
|
8
|
-
onClose?: (event: CloseEvent) => void;
|
|
9
|
-
onError?: (event: Event) => void;
|
|
10
|
-
};
|
|
11
|
-
host?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function connect(options: Options): Promise<WebSocket>;
|
|
14
|
-
export declare function connectToSocket(options: Options): Promise<WebSocket>;
|
|
15
|
-
export {};
|